Skip to content

Fix bugs in CSE Machine hanging during array access #1750

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

Merged
merged 31 commits into from
Apr 2, 2025
Merged

Conversation

alsonleej
Copy link
Contributor

@alsonleej alsonleej commented Mar 12, 2025

Description

Resolves #1749 and #1751 and completes #1740

Type of change

  • Bug fix (non-breaking change which fixes an issue)

now gives an error message instead of hanging for

  • trying to access array when LHS is not array
  • trying to spread array when RHS is not array

prevents crashing for

  • trying to access out of bounds array

Checklist

  • I have tested this code
  • I have updated the documentation

@coveralls
Copy link

coveralls commented Mar 12, 2025

Pull Request Test Coverage Report for Build 14197561406

Details

  • 19 of 21 (90.48%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.01%) to 81.11%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/cse-machine/interpreter.ts 14 16 87.5%
Totals Coverage Status
Change from base Build 13964710825: 0.01%
Covered Lines: 10803
Relevant Lines: 12949

💛 - Coveralls

@martin-henz martin-henz marked this pull request as draft March 14, 2025 05:02
@chuckyang123 chuckyang123 marked this pull request as ready for review March 14, 2025 05:02
@martin-henz
Copy link
Member

martin-henz commented Mar 14, 2025

Please add test cases to get good coverage of this fix.

@martin-henz
Copy link
Member

Quite a few warnings in src/cse-machine/interpreter.ts
Please take a look.

@alsonleej
Copy link
Contributor Author

alsonleej commented Mar 20, 2025

Bugfixes / enhancements:

  1. CSE Machine now shows error for accessing array with a) negative index and b) index > 2^31 -1, instead of simply crashing. For indices below 2^31 -1 but still out of range, the CSE Machine pushes an undefined to the stash. This is as per Source 3 specification.

image

  1. When testing it appears that no undefined is pushed to the stash, but it actually is, and it can be viewed by skipping to the last step. The animation for it is completed by CSE Machine: Added animation for spread instruction frontend#3114 , so when both changes are merged, the full effect is complete.

  2. Added test cases for spread operator, along with array access.

@alsonleej alsonleej requested a review from arnav-goel10 April 1, 2025 14:07
Copy link

@arnav-goel10 arnav-goel10 left a comment

Choose a reason for hiding this comment

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

LGTM!

@martin-henz martin-henz merged commit 4db615d into master Apr 2, 2025
4 checks passed
@martin-henz martin-henz deleted the arracc branch April 2, 2025 06:55
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.

CSE Machine: Stops without error message for array access
5 participants