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:
parent
dc5854689b
commit
24183d9a39
3 changed files with 21 additions and 2 deletions
|
@ -520,7 +520,11 @@
|
||||||
__extends(Call, Base);
|
__extends(Call, Base);
|
||||||
Call.prototype.children = ['variable', 'args'];
|
Call.prototype.children = ['variable', 'args'];
|
||||||
Call.prototype.newInstance = function() {
|
Call.prototype.newInstance = function() {
|
||||||
this.isNew = true;
|
if (this.variable.base instanceof Call) {
|
||||||
|
this.variable.base.newInstance();
|
||||||
|
} else {
|
||||||
|
this.isNew = true;
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
Call.prototype.superReference = function(o) {
|
Call.prototype.superReference = function(o) {
|
||||||
|
|
|
@ -433,7 +433,10 @@ exports.Call = class Call extends Base
|
||||||
|
|
||||||
# Tag this invocation as creating a new instance.
|
# Tag this invocation as creating a new instance.
|
||||||
newInstance: ->
|
newInstance: ->
|
||||||
@isNew = true
|
if @variable.base instanceof Call
|
||||||
|
@variable.base.newInstance()
|
||||||
|
else
|
||||||
|
@isNew = true
|
||||||
this
|
this
|
||||||
|
|
||||||
# Grab the reference to the superclass's implementation of the current
|
# Grab the reference to the superclass's implementation of the current
|
||||||
|
|
|
@ -346,6 +346,7 @@ eq ok, new ->
|
||||||
### Should `return` implicitly ###
|
### Should `return` implicitly ###
|
||||||
### even with trailing comments. ###
|
### even with trailing comments. ###
|
||||||
|
|
||||||
|
|
||||||
#855: execution context for `func arr...` should be `null`
|
#855: execution context for `func arr...` should be `null`
|
||||||
(->
|
(->
|
||||||
global = @
|
global = @
|
||||||
|
@ -355,3 +356,14 @@ eq ok, new ->
|
||||||
contextTest.apply null, array
|
contextTest.apply null, array
|
||||||
contextTest array...
|
contextTest array...
|
||||||
)()
|
)()
|
||||||
|
|
||||||
|
|
||||||
|
# #894: Splatting against constructor-chained functions.
|
||||||
|
x = null
|
||||||
|
|
||||||
|
class Foo
|
||||||
|
bar: (y) -> x = y
|
||||||
|
|
||||||
|
new Foo().bar([101]...)
|
||||||
|
|
||||||
|
eq x, 101
|
Loading…
Add table
Reference in a new issue