Skip to content

Conversation

alsonleej
Copy link
Contributor

@alsonleej alsonleej commented Feb 25, 2025

Description

Type of change

Deals with #1650

  • New feature (non-breaking change which adds functionality)

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

  • I have tested this code

TO-DO: run time check if RHS of spread operator is indeed an array

@martin-henz
Copy link
Member

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);

@martin-henz martin-henz self-requested a review February 26, 2025 06:16
const cont = control.getStack()
const size = control.size()
for (let i = size - 1; i >= 0; i--) {
// guaranteed at least one call instr above
Copy link
Member

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.

Copy link
Member

@martin-henz martin-henz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@coveralls
Copy link

Pull Request Test Coverage Report for Build 13545721578

Details

  • 8 of 20 (40.0%) changed or added relevant lines in 6 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.06%) to 81.596%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/cse-machine/interpreter.ts 1 13 7.69%
Totals Coverage Status
Change from base Build 13432508686: -0.06%
Covered Lines: 11473
Relevant Lines: 13674

💛 - Coveralls

@martin-henz martin-henz merged commit 1ec7669 into master Feb 26, 2025
3 of 4 checks passed
@martin-henz martin-henz deleted the spreadinstr branch February 26, 2025 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants