@@ -1297,7 +1297,6 @@ exports.Code = class Code extends Base
1297
1297
@params = params or []
1298
1298
@body = body or new Block
1299
1299
@bound = tag is ' boundfunc'
1300
- @context = ' _this' if @bound
1301
1300
1302
1301
children : [' params' , ' body' ]
1303
1302
@@ -1314,10 +1313,13 @@ exports.Code = class Code extends Base
1314
1313
# a closure.
1315
1314
compileNode : (o ) ->
1316
1315
1316
+ if @bound and o .scope .method ? .bound
1317
+ @context = o .scope .method .context
1318
+
1317
1319
# Handle bound functions early.
1318
- if @bound and not @wrapped and not @static
1319
- @wrapped = yes
1320
- wrapper = new Code [new Param new Literal ' _this ' ], new Block [this ]
1320
+ if @bound and not @context
1321
+ @context = ' _this '
1322
+ wrapper = new Code [new Param new Literal @context ], new Block [this ]
1321
1323
boundfunc = new Call (wrapper, [new Literal ' this' ])
1322
1324
boundfunc .updateLocationDataIfMissing @locationData
1323
1325
return boundfunc .compileNode (o)
@@ -1361,9 +1363,6 @@ exports.Code = class Code extends Base
1361
1363
node .error " multiple parameters named '#{ name} '" if name in uniqs
1362
1364
uniqs .push name
1363
1365
@body .makeReturn () unless wasEmpty or @noReturn
1364
- if @bound and o .scope .parent .method ? .bound
1365
- @bound = @context = o .scope .parent .method .context
1366
- idt = o .indent
1367
1366
code = ' function'
1368
1367
code += ' ' + @name if @ctor
1369
1368
code += ' ('
0 commit comments