-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Propagate errors in import #5728
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
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.
LG, just one suggestion to make the error observable in the test
fn F() { | ||
//@dump-sem-ir-begin | ||
WithError(()); |
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.
Noting that the generated IR doesn't include any errors (but I do note the absence of a call), I'd wonder if something like a let might show the transmission:
fn F() { | |
//@dump-sem-ir-begin | |
WithError(()); | |
fn F() { | |
//@dump-sem-ir-begin | |
let x: () = WithError(()); |
I think that'll yield:
+// CHECK:STDOUT: %x: %empty_tuple.type = bind_name x, <error> [concrete = <error>]
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.
Thanks, yep it does, exactly.
…5729) Currently if the first operand contains an error, we will return error, even though the second operands contains a runtime, and it has a stronger priority (the phase always goes up if possible). Import is only allowed on instructions with compile-time values, so we crash if we ever try to import a runtime value. Importable instructions must diagnose unexpected runtime values and produce errors in the semir from which they would be imported so that runtime values are never imported by another semir. If we had an instruction where you had an error value from the first operand, and runtime from the second, and we imported it: - Before #5728 we would crash in import, but only because we treated errors as runtime - After #5728 we would import ErrorInst because we propagate errors. This is desirable for cases with compile-time values and errors present only. - After this PR, we would crash again, cuz you're importing a runtime thing. This change means that instructions containing an `InstConstantKind::Never` instruction like`ValueParam` will consistently evaluate to a runtime value, even if there are errors present. This is visible in the `BindName` instructions changing in the semir, where they became constant `ErrorInst` values previously but no longer do.
AddImportedInstruction
was turning errors in an instruction into a Runtime constant value instead of an Error, which led to crashes when importing an instruction that had an error inside it somewhere.Fixes #5726