Boa: SyntaxError not generated for duplicate identifier names with let declarations

Created on 13 Oct 2020  路  2Comments  路  Source: boa-dev/boa

To Reproduce

>> let x = 12;
undefined
>> var x = 12;
undefined

Expected behavior
SyntaxError must be thrown by the parser. Environment is not supposed to deal with this according to the spec.

I think here is where the spec talks about syntax error in let declaration.

bug parser execution

All 2 comments

I think this section of the spec talks only when you declare two variables of the same name in the same declaration statement. Like: let x, x;

The example in the original post should throw an error during evaluation (execution).

Both cases in Boa are unhandled, and give the same panic.

I think I'm correct because I compared the following two in Chrome:

let x;
try {
  let x;
} catch (er) {}

undefined

try {
let x, x;
} catch (er) {}

Uncaught SyntaxError: Identifier 'x' has already been declared

The second case throws the error during parsing which is not catchable.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

neeldug picture neeldug  路  3Comments

attliaLin picture attliaLin  路  3Comments

Razican picture Razican  路  4Comments

jasonwilliams picture jasonwilliams  路  6Comments

IovoslavIovchev picture IovoslavIovchev  路  4Comments