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

Issue #894: Strange interaction between class instantiation and splats

This commit is contained in:
Jeremy Ashkenas 2010-12-05 15:08:41 -05:00
parent dc5854689b
commit 24183d9a39
3 changed files with 21 additions and 2 deletions

View file

@ -520,7 +520,11 @@
__extends(Call, Base);
Call.prototype.children = ['variable', 'args'];
Call.prototype.newInstance = function() {
this.isNew = true;
if (this.variable.base instanceof Call) {
this.variable.base.newInstance();
} else {
this.isNew = true;
}
return this;
};
Call.prototype.superReference = function(o) {

View file

@ -433,7 +433,10 @@ exports.Call = class Call extends Base
# Tag this invocation as creating a new instance.
newInstance: ->
@isNew = true
if @variable.base instanceof Call
@variable.base.newInstance()
else
@isNew = true
this
# Grab the reference to the superclass's implementation of the current

View file

@ -346,6 +346,7 @@ eq ok, new ->
### Should `return` implicitly ###
### even with trailing comments. ###
#855: execution context for `func arr...` should be `null`
(->
global = @
@ -355,3 +356,14 @@ eq ok, new ->
contextTest.apply null, array
contextTest array...
)()
# #894: Splatting against constructor-chained functions.
x = null
class Foo
bar: (y) -> x = y
new Foo().bar([101]...)
eq x, 101