-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Model the return slot as an output parameter #4432
Conversation
toolchain/sem_ir/typed_insts.h
Outdated
TypeId type_id; | ||
InstId value_id; |
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.
Comment? I'm guessing type_id
matches the return type of the function (though it might be good to separately associate the specific instruction representing that expression in the source for diagnostics). What is the value_id?
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.
OK, how's this?
(though it might be good to separately associate the specific instruction representing that expression in the source for diagnostics)
Do you see any places we can use that right now? If not, I'd rather wait until we have a need for it.
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, leaving for @josh11b to approve once he's happy.
toolchain/check/return.cpp
Outdated
@@ -42,7 +42,7 @@ static auto NoteReturnType(Context::DiagnosticBuilder& diag, | |||
SemIR::TypeId return_type_id) { | |||
CARBON_DIAGNOSTIC(ReturnTypeHereNote, Note, "return type of function is {0}", | |||
SemIR::TypeId); | |||
diag.Note(function.return_storage_id, ReturnTypeHereNote, return_type_id); | |||
diag.Note(function.return_slot_id, ReturnTypeHereNote, return_type_id); |
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.
Here is an example where it would be better to use an instruction id instead of a TypeId, so that we could match the spelling of the type the user wrote. We have been using TypeIds previously, but the goal is to switch.
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.
OK, given an InstId
representing the type expression the user wrote, how do I obtain the spelling the user wrote? Is there an existing example of the new pattern that I can follow to update this code?
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.
Use the type InstIdAsType
as the type of the diagnostic argument; search for that type name for examples.
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.
OK, done.
Also fix
Param
insts to have meaningful names in pretty-printing, to help clarify relationship with return slot.