Permalink
Browse files

Never return from a constructor.

  • Loading branch information...
1 parent 9e4fa02 commit a8a581acaecb5944109b0b224485203da14a4754 @jashkenas jashkenas committed May 10, 2011
Showing with 3 additions and 2 deletions.
  1. +1 −1 lib/nodes.js
  2. +1 −1 src/nodes.coffee
  3. +1 −0 test/classes.coffee
View
2 lib/nodes.js
@@ -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
2 src/nodes.coffee
@@ -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
1 test/classes.coffee
@@ -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

0 comments on commit a8a581a

Please sign in to comment.