You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
array is correctly destructured and running the code should not lead to runtime error
Current Behavior
running the code leads to following runtime error:
TypeError: Array.prototype.splice called on null or undefined
js code produced by CS 2.2.2:
// Generated by CoffeeScript 2.2.2(function(){vararray,splice=[].splice;array=[1,2,3,4,5];[...this.all_but_last_two]=array,[this.penultimate,this.last]=splice.call(undefined,-2);}).call(this);
note the splice.call(undefined, -2); which should have been splice.call(this.all_but_last_two, -2);
Additional Notes
output from CS 2.1.1 ( which works as expected )
// Generated by CoffeeScript 2.1.1(function(){vararray,i,slice=[].slice;array=[1,2,3,4,5];this.all_but_last_two=3<=array.length ? slice.call(array,0,i=array.length-2) : (i=0,[]),this.penultimate=array[i++],this.last=array[i++];}).call(this);
zdenko
changed the title
array destructuring is broken in some cases and leads to TypeError
Nodes: array destructuring is broken in some cases and leads to TypeError
Mar 5, 2018
bug report
when destructuring an array into properties on
this
, in some cases incorrect code is generated which leads to runtime error when executedInput Code
Expected Behavior
array is correctly destructured and running the code should not lead to runtime error
Current Behavior
running the code leads to following runtime error:
js code produced by CS 2.2.2:
note the
splice.call(undefined, -2);
which should have beensplice.call(this.all_but_last_two, -2);
Additional Notes
output from CS 2.1.1 ( which works as expected )
The bug has probably been introduced by #4825.
if we change
@all_but_last_two
toall_but_last_two
the problem disappearsEnvironment
The text was updated successfully, but these errors were encountered: