New issue
Advanced search Search tips

Issue 875024 link

Starred by 4 users

Issue metadata

Status: Duplicate
Merged: issue 679274
Owner:
Closed: Aug 16
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug



Sign in to add a comment

Can't re-declare block-scoped (let/const) global variable in console

Reported by sophieb...@gmail.com, Aug 16

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36

Steps to reproduce the problem:
1. Run `let x = 1;` in console.
2. Run `let x = 2;` in console.

What is the expected behavior?
Redeclaring a variable with `let` or `const` is an error in JS, but it would be nice for debugging purposes if this was allowed in top-level statements in the console.

In particular, it means you need to manually wrap code blocks in an IIFE when revising them – or switch from let/const to var – in order to avoid this error.

What went wrong?
Uncaught SyntaxError: Identifier 'x' has already been declared

(Same happens with `const`.)

Did this work before? No 

Chrome version: 68.0.3440.106  Channel: stable
OS Version: OS X 10.13.4
Flash Version: 

Perhaps one way to implement this would be to convert all global vars' internal type from let/const to var after each console execution.
 
Owner: kozy@chromium.org
Status: Assigned (was: Unconfirmed)
Oh, this turns out to be a dupe of https://bugs.chromium.org/p/chromium/issues/detail?id=679274.
Mergedinto: 679274
Status: Duplicate (was: Assigned)

Sign in to add a comment