Skip to content

Commit e46b129

Browse files
committed
Remove return statement on auto-generated constructors
1 parent 35787ef commit e46b129

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

lib/coffee-script/nodes.js

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/nodes.coffee

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,6 @@ exports.Class = class Class extends Base
956956
@ctor = new Code
957957
@ctor.body.push new Literal "#{name}.__super__.constructor.apply(this, arguments)" if @parent
958958
@ctor.body.push new Literal "#{@externalCtor}.apply(this, arguments)" if @externalCtor
959-
@ctor.body.makeReturn()
960959
@body.expressions.unshift @ctor
961960
@ctor.ctor = @ctor.name = name
962961
@ctor.klass = null

test/classes.coffee

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -595,11 +595,6 @@ test "#1813: Passing class definitions as expressions", ->
595595

596596
eq result, B
597597

598-
test "#1966: external constructors should produce their return value", ->
599-
ctor = -> {}
600-
class A then constructor: ctor
601-
ok (new A) not instanceof A
602-
603598
test "#1980: regression with an inherited class with static function members", ->
604599

605600
class A
@@ -676,3 +671,14 @@ test "#2052: classes should work in strict mode", ->
676671
class A
677672
catch e
678673
ok no
674+
675+
test "#2359: instanceof should work when extending native objects", ->
676+
class MyError extends Error
677+
ok new MyError instanceof MyError
678+
679+
test '#2359: external constructors returning "other typed" objets', ->
680+
ctor = -> {}
681+
class A then constructor: ctor
682+
ok new A instanceof A
683+
ok new ctor not instanceof A
684+
ok new ctor not instanceof ctor

0 commit comments

Comments
 (0)