ChakraCore
ChakraCore copied to clipboard
chakra can't recognize spread_syntax
Version
chakra-1.11.24.0
Test case 1
var foo = function() {
var o = [1,2,3];
var a = [...o];
print(a);
};
foo();
Execution steps 1
./ChakraCore/out/Release/ch Testcase1.js
Output 1
1,2,3
Test case 2
var foo = function() {
var o = [1, 2, 3];
var b = {...o};
print(b);
};
foo();
Execution steps 2
./ChakraCore/out/Release/ch Testcase2.js
Output 2
SyntaxError: Expected identifier, string or number at code (Testcase2.js:3:14)
Expected behavior 2
[object Object]
Description
When executing the above two test cases that both contain a spread operator .... When the operator ... is used in an array assignment statement at line 3 in Test case 1, the test case can be executed normally and output the correct result. But when it is used in an object assignment statement at line 3 in Test case 2, a SyntaxError exception was thrown shown as Output 2. I executed both test cases on other JS engines and they all output excepted results. I think it might be an issue of chakra.
Reference
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax