From 5dbaa47f89dc7b61c8c06cfa21d7f32a942c29e1 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 30 Jun 2024 12:58:32 +0800 Subject: [PATCH] MIR Lower - Allow `Foo { ... }` on tuple-structs --- src/mir/from_hir_match.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/mir/from_hir_match.cpp b/src/mir/from_hir_match.cpp index 0a8aa55f..716eba3c 100644 --- a/src/mir/from_hir_match.cpp +++ b/src/mir/from_hir_match.cpp @@ -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);