Skip to content

Commit 080ed2e

Browse files
fixes #1966: external constructors should produce their return value
1 parent 0c4cb30 commit 080ed2e

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

lib/coffee-script/nodes.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/nodes.coffee

+1
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,7 @@ exports.Class = class Class extends Base
923923
@ctor = new Code
924924
@ctor.body.push new Literal "#{name}.__super__.constructor.apply(this, arguments)" if @parent
925925
@ctor.body.push new Literal "#{@externalCtor}.apply(this, arguments)" if @externalCtor
926+
@ctor.body.makeReturn()
926927
@body.expressions.unshift @ctor
927928
@ctor.ctor = @ctor.name = name
928929
@ctor.klass = null

test/classes.coffee

+6
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ test "#1182: execution order needs to be considered as well", ->
490490
test "#1182: external constructors with bound functions", ->
491491
fn = ->
492492
{one: 1}
493+
this
493494
class B
494495
class A
495496
constructor: fn
@@ -604,3 +605,8 @@ test "#494: Named classes", ->
604605

605606
class A.B["C"]
606607
ok A.B.C.name isnt 'C'
608+
609+
test "#1966: external constructors should produce their return value", ->
610+
ctor = -> {}
611+
class A then constructor: ctor
612+
ok (new A) not instanceof A

0 commit comments

Comments
 (0)