Skip to content

Commit

Permalink
MIR Lower - Allow Foo { ... } on tuple-structs
Browse files Browse the repository at this point in the history
  • Loading branch information
thepowersgang committed Jun 30, 2024
1 parent ded4884 commit 5dbaa47
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/mir/from_hir_match.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1556,6 +1556,17 @@ void PatternRulesetBuilder::append_from(const Span& sp, const ::HIR::Pattern& pa
m_field_path.back() ++;
}
}
TU_ARMA(PathNamed, pe) {
// Only allow with an empty tuple (assuming that the pattern is also empty)... or if the pattern is a wildcard
if( sd.size() != 0 && !pe.is_wildcard() ) {
BUG(sp, "Match not allowed, " << ty << " with " << pat);
}
for(const auto& fld : sd)
{
this->append_from(sp, empty_pattern, maybe_monomorph(fld.ent));
m_field_path.back() ++;
}
}
TU_ARMA(PathTuple, pe) {
assert( pe.binding.is_Struct() );
PH::push_pattern_tuple(*this, sp, pe, maybe_monomorph);
Expand Down

0 comments on commit 5dbaa47

Please sign in to comment.