diff options
-rw-r--r-- | src/convert/ast_iterate.cpp | 4 | ||||
-rw-r--r-- | src/parse/pattern.cpp | 5 |
2 files changed, 5 insertions, 4 deletions
diff --git a/src/convert/ast_iterate.cpp b/src/convert/ast_iterate.cpp index 153fc1c9..b474a755 100644 --- a/src/convert/ast_iterate.cpp +++ b/src/convert/ast_iterate.cpp @@ -76,8 +76,8 @@ void CASTIterator::handle_pattern(AST::Pattern& pat, const TypeRef& type_hint) auto& v = pat.data().as_Ref(); if( type_hint.is_wildcard() ) handle_pattern(*v.sub, (const TypeRef&)TypeRef()); - else if( type_hint.is_reference() ) - throw ::std::runtime_error("Ref pattern on non-ref value"); + else if( !type_hint.is_reference() ) + throw ::std::runtime_error( FMT("Ref pattern on non-ref value: " << type_hint) ); else handle_pattern(*v.sub, type_hint.sub_types()[0]); break; } diff --git a/src/parse/pattern.cpp b/src/parse/pattern.cpp index 7113f94b..28e7ebaa 100644 --- a/src/parse/pattern.cpp +++ b/src/parse/pattern.cpp @@ -149,11 +149,12 @@ AST::Pattern Parse_PatternReal1(TokenStream& lex) return AST::Pattern( AST::Pattern::TagWildcard() ); case TOK_AMP: DEBUG("Ref"); + // NOTE: Falls back into "Pattern" not "PatternReal" to handle MaybeBind again if( GET_TOK(tok, lex) == TOK_RWORD_MUT ) // TODO: Actually use mutability - return AST::Pattern( AST::Pattern::TagReference(), Parse_PatternReal(lex) ); + return AST::Pattern( AST::Pattern::TagReference(), Parse_Pattern(lex) ); lex.putback(tok); - return AST::Pattern( AST::Pattern::TagReference(), Parse_PatternReal(lex) ); + return AST::Pattern( AST::Pattern::TagReference(), Parse_Pattern(lex) ); case TOK_IDENT: lex.putback(tok); return Parse_PatternReal_Path( lex, Parse_Path(lex, false, PATH_GENERIC_EXPR) ); |