-
Notifications
You must be signed in to change notification settings - Fork 107
Implements new spread instruction #1740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
TO-DO: run time check if RHS of spread operator is indeed an array What happens if the RHS of spread is not an array? Can you try: math_max(... 1); |
src/cse-machine/interpreter.ts
Outdated
const cont = control.getStack() | ||
const size = control.size() | ||
for (let i = size - 1; i >= 0; i--) { | ||
// guaranteed at least one call instr above |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...because spread in arrays is currently not allowed in Source.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Pull Request Test Coverage Report for Build 13545721578Details
💛 - Coveralls |
Description
Type of change
Deals with #1650
How to test
const f = (...x) => x;
// one spread
// f(...[1, 2, 3]);
// empty array spread
// f(...[]);
// literals, empty array, multiple spreads
// f(0, ...[1, 2], ...[3, 4], ...[], ...[6], 7);
// array reference
// const rr = [1,2,3];
// f(...rr, 3);
// function returning array
// const k = () => [1, 2, 3];
// const g = (...x) => x;
// g(...k()); // Expected: [1, 2, 3]
Checklist
TO-DO: run time check if RHS of spread operator is indeed an array