Skip to content

Commit

Permalink
fixed bound constructor with backcall
Browse files Browse the repository at this point in the history
  • Loading branch information
satyr committed Nov 21, 2012
1 parent 0804bc3 commit 6117604
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -2199,7 +2199,7 @@ exports.Fun = Fun = (function(superclass){
if (this.bound === 'this$') {
if (this.ctor) {
scope.assign('this$', 'this instanceof ctor$ ? this : new ctor$');
body.add(Return(Literal('this$')));
body.lines.push(Return(Literal('this$')));
} else if (that = (ref$ = sscope.fun) != null ? ref$.bound : void 8) {
this.bound = that;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/ast.co
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,7 @@ class exports.Fun extends Node
if @bound is \this$
if @ctor
scope.assign \this$ 'this instanceof ctor$ ? this : new ctor$'
body.add Return Literal \this$
body.lines.push Return Literal \this$
else if sscope.fun?bound
then @bound = that
else sscope.assign \this$ \this
Expand Down
6 changes: 5 additions & 1 deletion test/oo.co
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ class BoundCtor extends (-> {@attr})
eq super(...).attr, @attr
@method = ~> this

class BoundChild extends BoundCtor then ~> super ...
class BoundChild extends BoundCtor
~>
super ...
# Auto-`return this` even with backcall.
<- Object

for C of [BoundCtor, BoundChild]
bc = C 'attr'
Expand Down

0 comments on commit 6117604

Please sign in to comment.