Bug 185156
Summary: | JavaScriptCore should throw SyntaxError when a variable is already declared inside the "with" scope | ||
---|---|---|---|
Product: | WebKit | Reporter: | baac |
Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
Status: | NEW | ||
Severity: | Normal | CC: | isol2, mark.lam, saam, ysuzuki |
Priority: | P2 | ||
Version: | Safari 11 | ||
Hardware: | Unspecified | ||
OS: | Linux |
baac
Hi,
there is an inconsistency when a variable is declared twice as "var" and "let" inside the "with" scope. JavaScriptCore should not accept the redeclaration and indicate an error.
OS: Ubuntu 17.10
JavaScriptCore: 606.1.9.4
Step to reproduce:
with({}) {
var a;
let a;
}
Actual result:
Pass without failures
Expected result:
SyntaxError: Cannot declare a variable twice
V8 and SpiderMonkey raises an exception as expected.
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Saam Barati
This is surprising given:
if (b) {
var a;
let a;
}
Is not a syntax error. Since with scopes don't require a block as their statement, e.g
```with({}) 20;```
is valid, I would guess this might be a bug in those other engines.
Can you point me to where the spec says this should be a syntax error?
isol2
Hi Saam, sorry for delay... baac left from our project she did not answered your question in time.
We reported this issue on JSC and Chakra already confirmed after discussion (https://github.com/Microsoft/ChakraCore/issues/5076).
Another similar case can be found in this code:
{
let x;
eval('var x;');
}
JSC and Chakra should not hoist the var past the let declaration without throwing redeclaration. V8 and Spidermonkey throws a SyntaxError as expected.
cinfuzz