fixing off-by-one error in compile_splat_arguments

This commit is contained in:
Jeremy Ashkenas 2010-03-17 22:07:11 -04:00
parent 6fd7810d89
commit 884637468e
3 changed files with 6 additions and 2 deletions

View File

@ -489,7 +489,7 @@
args[i - 1] = '' + (prev.substr(0, prev.length - 2)) + ", " + code + "]"; args[i - 1] = '' + (prev.substr(0, prev.length - 2)) + ", " + code + "]";
continue; continue;
} else if (i > 1 && prev.substr(8, 1) === '[' && prev.substr(prev.length - 2, 1) === ']') { } else if (i > 1 && prev.substr(8, 1) === '[' && prev.substr(prev.length - 2, 1) === ']') {
args[i - 1] = '' + (prev.substr(0, prev.length - 3)) + ", " + code + "])"; args[i - 1] = '' + (prev.substr(0, prev.length - 2)) + ", " + code + "])";
continue; continue;
} else { } else {
code = "[" + code + "]"; code = "[" + code + "]";

View File

@ -378,7 +378,7 @@ exports.CallNode: class CallNode extends BaseNode
args[i - 1]: "${prev.substr(0, prev.length - 2)}, $code]" args[i - 1]: "${prev.substr(0, prev.length - 2)}, $code]"
continue continue
else if i > 1 and prev.substr(8, 1) is '[' and prev.substr(prev.length - 2, 1) is ']' else if i > 1 and prev.substr(8, 1) is '[' and prev.substr(prev.length - 2, 1) is ']'
args[i - 1]: "${prev.substr(0, prev.length - 3)}, $code])" args[i - 1]: "${prev.substr(0, prev.length - 2)}, $code])"
continue continue
else else
code: "[$code]" code: "[$code]"

View File

@ -45,6 +45,10 @@ ok bronze is "Mighty Mouse"
ok last is "Michael Phelps" ok last is "Michael Phelps"
ok the_field.length is 8 ok the_field.length is 8
medalists contenders..., 'Tim', 'Bob', 'Jim'
ok last is 'Jim'
obj: { obj: {
name: 'bob' name: 'bob'
accessor: (args...) -> accessor: (args...) ->