mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-25 06:20:11 +01:00
Add support for _ placeholder. (#661)
Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
co-authored by
Jon Meow
parent
c3c89a77a4
commit
def98d1182
@@ -384,9 +384,13 @@ auto PatternMatch(const Value* p, const Value* v, Env values,
|
||||
-> std::optional<Env> {
|
||||
switch (p->tag()) {
|
||||
case ValKind::BindingPlaceholderValue: {
|
||||
Address a = state->heap.AllocateValue(CopyVal(v, line_num));
|
||||
vars->push_back(p->GetBindingPlaceholderValue().name);
|
||||
values.Set(p->GetBindingPlaceholderValue().name, a);
|
||||
const BindingPlaceholderValue& placeholder =
|
||||
p->GetBindingPlaceholderValue();
|
||||
if (placeholder.name.has_value()) {
|
||||
Address a = state->heap.AllocateValue(CopyVal(v, line_num));
|
||||
vars->push_back(*placeholder.name);
|
||||
values.Set(*placeholder.name, a);
|
||||
}
|
||||
return values;
|
||||
}
|
||||
case ValKind::TupleValue:
|
||||
|
||||
Reference in New Issue
Block a user