Repository navigation
Make a failing instanceof, and a condition with no value, a real error - #353
Merged
Merged
Conversation
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
A failure inside the generated
___unbox<C>was swallowed.<C>anyValuecompiled into a cast that always throws "Can't cast from any type", and no error was shown. Two bugs combined:mlirGenInstanceOfOpaquereported failure as a nullmlir::Value.ValueOrLogicalResulttreats a null value as success with no value, so callers passed the failure on as a success. It now returns aValueOrLogicalResultwith a real failure on every path. Its internalEXIT_IF_FAILED_OR_NO_VALUEuses would have leaked "no value" the same way, so they are explicit failures now.A condition with no value was taken for success.
ifandwhileusedEXIT_IF_FAILED_OR_NO_VALUE, which returns the value itself;doandforchecked only for failure. The newconditionHasValuerejects a present condition that yields no value, with "the condition has no value". The message is postponed like every other one and shown only if compilation fails. Onmain, with a void call as the condition:mainif___unboxit dropped theif (a instanceof C) return a;testforfor (;;)spells "no condition"domlir::Value)whileTypeScript also rejects testing a
voidvalue for truthiness.Verification
mlirGenInstanceOfOpaque, the untyped-catch cast, plaininstanceofandinstanceofnarrowing all stop with the real error. The first of those used to compile into an always-throwing cast.test/tester/condition-value/{if,while,do,for}.ts. Each must print "the condition has no value", and must not print a stack dump or an assertion.A correction to the note in #352: a failed generic instantiation does not leave its function in the module to be reused. The
FuncOpis created detached and a failed body never reaches the module. The swallowing was entirely the two bugs above.🤖 Generated with Claude Code