ES6 class syntax should use block scoping
authorsaambarati1@gmail.com <saambarati1@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 31 Jul 2015 21:05:19 +0000 (21:05 +0000)
committersaambarati1@gmail.com <saambarati1@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 31 Jul 2015 21:05:19 +0000 (21:05 +0000)
commit06e39138750d32d2f4036718e2b8753ec4ac8edf
tree93250a96ded5432955e3c0a81fe58dbe62c31a7a
parent79fe1791163336cf2c8250638f5b6073eb4b1b4a
ES6 class syntax should use block scoping
https://bugs.webkit.org/show_bug.cgi?id=142567

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

We treat class declarations like we do "let" declarations.
The class name is under TDZ until the class declaration
statement is evaluated. Class declarations also follow
the same rules as "let": No duplicate definitions inside
a lexical environment.

* parser/ASTBuilder.h:
(JSC::ASTBuilder::createClassDeclStatement):
* parser/Parser.cpp:
(JSC::Parser<LexerType>::parseClassDeclaration):
* tests/stress/class-syntax-block-scoping.js: Added.
(assert):
(truth):
(.):
* tests/stress/class-syntax-definition-semantics.js: Added.
(shouldBeSyntaxError):
(shouldNotBeSyntaxError):
(truth):
* tests/stress/class-syntax-tdz.js:
(assert):
(shouldThrowTDZ):
(truth):
(.):

LayoutTests:

* js/class-constructor-return-expected.txt:
* js/class-syntax-call-expected.txt:
* js/class-syntax-declaration-expected.txt:
* js/class-syntax-default-constructor-expected.txt:
* js/class-syntax-extends-expected.txt:
* js/class-syntax-name-expected.txt:
* js/class-syntax-super-expected.txt:
* js/script-tests/class-constructor-return.js:
(shouldThrow):
(shouldNotThrow):
(shouldBeTrue):
(shouldBeFalse):
* js/script-tests/class-syntax-call.js:
(A):
(B):
(shouldThrow):
(shouldNotThrow):
* js/script-tests/class-syntax-declaration.js:
(shouldThrow):
(shouldNotThrow):
(shouldBe):
* js/script-tests/class-syntax-default-constructor.js:
(shouldThrow):
(shouldBe):
(shouldBeTrue):
(assert):
(A):
(B):
* js/script-tests/class-syntax-extends.js:
(shouldThrow):
(shouldNotThrow):
(shouldBe):
(shouldBeTrue):
(Base):
(Base.prototype.baseMethod):
* js/script-tests/class-syntax-name.js:
(shouldThrow):
(shouldNotThrow):
(shouldBe):
(shouldBeTrue):
(runTestShouldBe):
* js/script-tests/class-syntax-super.js:
(shouldThrow):
(shouldNotThrow):
(shouldBe):
(shouldBeTrue):
(shouldBeFalse):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@187680 268f45cc-cd09-0410-ab3c-d52691b4dbfc
27 files changed:
LayoutTests/ChangeLog
LayoutTests/js/class-constructor-return-expected.txt
LayoutTests/js/class-syntax-call-expected.txt
LayoutTests/js/class-syntax-declaration-expected.txt
LayoutTests/js/class-syntax-default-constructor-expected.txt
LayoutTests/js/class-syntax-extends-expected.txt
LayoutTests/js/class-syntax-name-expected.txt
LayoutTests/js/class-syntax-super-expected.txt
LayoutTests/js/intl-collator-expected.txt
LayoutTests/js/intl-datetimeformat-expected.txt
LayoutTests/js/intl-numberformat-expected.txt
LayoutTests/js/script-tests/class-constructor-return.js
LayoutTests/js/script-tests/class-syntax-call.js
LayoutTests/js/script-tests/class-syntax-declaration.js
LayoutTests/js/script-tests/class-syntax-default-constructor.js
LayoutTests/js/script-tests/class-syntax-extends.js
LayoutTests/js/script-tests/class-syntax-name.js
LayoutTests/js/script-tests/class-syntax-super.js
LayoutTests/js/script-tests/intl-collator.js
LayoutTests/js/script-tests/intl-datetimeformat.js
LayoutTests/js/script-tests/intl-numberformat.js
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/parser/ASTBuilder.h
Source/JavaScriptCore/parser/Parser.cpp
Source/JavaScriptCore/tests/stress/class-syntax-block-scoping.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/class-syntax-definition-semantics.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/class-syntax-tdz.js