Ignore:
Timestamp:
Sep 23, 2015, 3:37:36 PM (10 years ago)
Author:
[email protected]
Message:

JSC allows invalid var declarations when the declared name is the same as a let/const variable
https://bugs.webkit.org/show_bug.cgi?id=147600

Reviewed by Yusuke Suzuki.

Source/JavaScriptCore:

We had an ordering bug where if you first declared a "let"
variable then a "var" variable with the same name, you wouldn't
get a syntax error. But, if you did it in the reverse order,
you would. This patch fixes this syntax error to be order independent.

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseVariableDeclarationList):
(JSC::Parser<LexerType>::createBindingPattern):
(JSC::Parser<LexerType>::parseFunctionDeclaration):

  • parser/Parser.h:

(JSC::Scope::declareVariable):

LayoutTests:

  • js/let-syntax-expected.txt:
  • js/script-tests/let-syntax.js:

(hasSyntaxError):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/Parser.h

    r189371 r190188  
    320320        if (!isValidStrictMode)
    321321            result |= DeclarationResult::InvalidStrictMode;
     322        if (m_lexicalVariables.contains(ident->impl()))
     323            result |= DeclarationResult::InvalidDuplicateDeclaration;
    322324        return result;
    323325    }
Note: See TracChangeset for help on using the changeset viewer.