Add support for _ placeholder. (#661)

Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
This commit is contained in:
Geoff Romer
2021-07-19 10:33:06 -07:00
committed by GitHub
co-authored by Jon Meow
parent c3c89a77a4
commit def98d1182
15 changed files with 88 additions and 20 deletions
@@ -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: