Fix 2 more not-implemented crashes: typeof-dispatch cast helpers - #299
Merged
Conversation
castPrimitiveTypeFromAny (the __unbox<T> helper, generic type-param
unboxing from any) was dead code - its one call site already only passes
types the TypeSwitch handles - but fixed anyway (crash -> emitError) for
consistency, since location was already in scope.
castFromUnion is a real, easily-reachable crash: any union type with a
tuple/object-literal-shaped member (e.g. `number | {a: number}`) crashes
the moment it needs a runtime cast, since the typeof-dispatch TypeSwitch
never got a TupleType/ConstTupleType case. The function's own forward-decl
already carries a TODO acknowledging typeof-based dispatch can't handle
this properly (can't even distinguish two different tuple shapes from each
other) - a real redesign, out of scope here. Converted the crash to a clean
error instead.
Closes out MLIRGenCast.cpp's two TypeOf sites, the last item from the
original not-implemented-audit's §5.1 named/specific list.
829/829 ctest, no regressions.
2 tasks
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.
Summary
Continuation of the not-implemented-audit crash-to-error sweep (follow-up to #297/#298), closing out the last item from the audit's original §5.1 named/specific list:
castPrimitiveTypeFromAny(the__unbox<T>generic type-param unboxing helper) — dead code, its one call site already only passes types the switch handles, but fixed for consistencycastFromUnion— a real, easily-reachable crash: any union type with a tuple/object-literal-shaped member (e.g.number | {a: number}) crashes the moment it needs a runtime cast, since thetypeof-dispatch codegen never got aTupleType/ConstTupleTypecase. The function's own forward-declaration already carries a TODO acknowledging the deeper design limitation (can't even distinguish two different tuple shapes from each other viatypeof) — a real redesign, out of scope here; this PR just converts the crash into a clean compile error.docs/not-implemented-audit.mdupdated with the full writeup (§4.9).Test plan
number | {a:number}cast tonumber) verified: clean diagnostic, no crashctest -C Debug -j8→ 829/829, no regressions🤖 Generated with Claude Code