1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

Never return from a constructor.

This commit is contained in:
Jeremy Ashkenas 2011-05-10 10:03:22 -04:00
parent 9e4fa02cdb
commit a8a581acae
3 changed files with 3 additions and 2 deletions

View file

@ -1102,7 +1102,7 @@
this.ctor.body.push(new Literal("" + name + ".__super__.constructor.apply(this, arguments)"));
}
if (this.externalCtor) {
this.ctor.body.push(new Literal("return " + this.externalCtor + ".apply(this, arguments)"));
this.ctor.body.push(new Literal("" + this.externalCtor + ".apply(this, arguments)"));
}
this.body.expressions.unshift(this.ctor);
}

View file

@ -862,7 +862,7 @@ exports.Class = class Class extends Base
if not @ctor
@ctor = new Code
@ctor.body.push new Literal "#{name}.__super__.constructor.apply(this, arguments)" if @parent
@ctor.body.push new Literal "return #{@externalCtor}.apply(this, arguments)" if @externalCtor
@ctor.body.push new Literal "#{@externalCtor}.apply(this, arguments)" if @externalCtor
@body.expressions.unshift @ctor
@ctor.ctor = @ctor.name = name
@ctor.klass = null

View file

@ -470,6 +470,7 @@ test "#1182: execution order needs to be considered as well", ->
test "#1182: external constructors with bound functions", ->
fn = ->
{one: 1}
class B
class A
constructor: fn