-
-
Notifications
You must be signed in to change notification settings - Fork 114
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
fix(compiler): Provide appropriate error during invalid array access #1556
Conversation
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.
Couple of questions
), | ||
Expression.Block.make( | ||
wasm_mod, | ||
gensym_label("IndexNotSimpleInteger"), |
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.
I feel like this is a symptom that XX.toNumber
should reduce its argument to the smallest containing integer, rather than be a no-op...
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.
I think how it works now is correct (since the flexibility is the point of Number), but we should definitely have a utility that does let you round/truncate. It gets kinda hairy for floats, since we support bigints. My basic math tells me that the worst case conversion of a float64 to a bigint would be a bigint with 16 limbs, so maybe not actually so bad.
That said though, I could see us converting whole numbers to ints. 3.0
becoming 3
, that sort of thing.
But yeah, food for thought.
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.
LGTM; I left one piece of food for thought, but that's beyond the scope of this PR.
This PR fixes an issue where a potential non-integer or heap-allocated index for an array get/set may not result in an error. It also provides a better error for non-integer indexes.