Skip to content
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

Remove SelfParam, add an AddrPattern instead. #3506

Merged
merged 5 commits into from
Dec 14, 2023

Conversation

zygoloid
Copy link
Contributor

This is intended to make the representation of a self pattern be more similar to other patterns.

This is intended to make the representation of a `self` pattern be more
similar to other patterns.
Copy link
Contributor

@jonmeow jonmeow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

toolchain/check/handle_binding_pattern.cpp Outdated Show resolved Hide resolved
Comment on lines +82 to +87
auto inst = sem_ir.insts().Get(param_id);
if (auto addr = inst.TryAs<SemIR::AddrPattern>()) {
inst = sem_ir.insts().Get(addr->inner_id);
}
if (auto param = inst.TryAs<SemIR::Param>();
param && param->name_id == SemIR::NameId::SelfValue) {
Copy link
Contributor

@jonmeow jonmeow Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code matches what's in convert.cpp, differing only on what's done with param. Not sure it's worth a like TryGetAsSelfValueParam or similar, but might be worth considering.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can take another look once ConvertCallArgs is also handling deduced parameters. They might look less similar at that point.

Comment on lines +33 to +36
auto HandleAddrPattern(FunctionContext& /*context*/, SemIR::InstId /*inst_id*/,
SemIR::AddrPattern /*inst*/) -> void {
CARBON_FATAL() << "`addr` should be lowered by `BuildFunctionDefinition`";
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth moving all the fatal handlers to their own file, like handle_unused?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will send a PR.

Comment on lines 451 to 452
// TODO: Visit the entire parameter block, not just the parameter
// refs, so that we visit the parameter inside an `addr` pattern.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an issue where patterns generally need to be recursed through? I'll offer some concern that walking the entire parameter block might not yield the right result either, due to separate use of blocks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched TODO to just describe the problem rather than suggesting a solution.

@zygoloid zygoloid added this pull request to the merge queue Dec 14, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 14, 2023
@zygoloid zygoloid added this pull request to the merge queue Dec 14, 2023
Merged via the queue into carbon-language:trunk with commit fbb4ecf Dec 14, 2023
6 checks passed
@zygoloid zygoloid deleted the generic-param branch December 14, 2023 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants