Repository navigation
A value a builtin cannot cast is an error, not a compiler crash (#438) - #496
Merged
Merged
Conversation
`h.push(() => 1)` into `(() => number)[]` crashed the compiler (0xC0000005) with no message: `() => 1` is `() => s32`, the cast to the element type fails, and push, unshift and splice handed the null value it gave to the op's builder. The cast's own error now stops them: "can't assign '() => s32' to '() => number': return type 's32' is not 'number'", the message an assignment gives. The builtins in MLIRCodeLogic.h that took a castFn result without looking at it now check it as well: - push, unshift, splice and view, through one castEach; - splice's start and delete count; - sprintf's buffer size and format, assert's condition; - parseInt, parseFloat and isNaN, which now return ValueOrLogicalResult (parseInt(() => 1) and isNaN(() => 1) crashed too); - __switchstate's state, and a constant array made into an array for an array method. Closes #438 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
h.push(() => 1)into a(() => number)[]crashed the compiler (0xC0000005) with no message.() => 1is a() => s32, so the cast to the element type fails.push,unshiftandsplicethen passed the cast's null result to the op's builder. Now the cast's own error stops them, the same message an assignment gives:The builtins in
MLIRCodeLogic.hthat used acastFnresult without checking it now check it too:push,unshift,spliceandview, through onecastEachhelper;splice's start and delete count;sprintf's buffer size and format, andassert's condition;parseInt,parseFloatandisNaN, which now returnValueOrLogicalResult.parseInt(() => 1)andisNaN(() => 1)crashed onmaintoo.__switchstate's state, and a constant array converted to an array for an array method.Tests:
builtin-cast/*.ts: expect the error forpush,unshift,splice, a function pushed into astring[],parseIntandisNaN. Each one crashes onmain.00array_insert_functions.ts: functions whose type matches the element type still go in throughpush,unshiftandsplice, and each calls correctly.weakref_basicis gc-only, as onmain)nin several escaping closures.Closes #438
🤖 Generated with Claude Code