ES6: Classes: Early return in sub-class constructor results in returning undefined...
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Mar 2015 01:18:18 +0000 (01:18 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Mar 2015 01:18:18 +0000 (01:18 +0000)
commitc1b58e55251e93b9efc0eb8ecb7327e645b2e163
tree22d0bc46131f526c01c957ab2cba2e838aa8551a
parent2b49a66936cad1c6895a794e38f1fdedeedcbbce
ES6: Classes: Early return in sub-class constructor results in returning undefined instead of instance
https://bugs.webkit.org/show_bug.cgi?id=143012

Reviewed by Ryosuke Niwa.

Source/JavaScriptCore:

* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::emitReturn):
Fix handling of "undefined" when returned from a Derived class. It was
returning "undefined" when it should have returned "this".

LayoutTests:

* js/class-constructor-return-expected.txt: Added.
* js/class-constructor-return.html: Added.
* js/script-tests/class-constructor-return.js: Added.
New test covering different return values from constructors.

* js/class-syntax-super-expected.txt:
* js/script-tests/class-syntax-super.js:
Fix test. Returning undefined is the same as an implicit return
and should return `this`.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181924 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/js/class-constructor-return-expected.txt [new file with mode: 0644]
LayoutTests/js/class-constructor-return.html [new file with mode: 0644]
LayoutTests/js/class-syntax-super-expected.txt
LayoutTests/js/script-tests/class-constructor-return.js [new file with mode: 0644]
LayoutTests/js/script-tests/class-syntax-super.js
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp