diff options
author | John Hodge <tpg@mutabah.net> | 2015-03-25 14:44:21 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2015-03-25 14:44:21 +0800 |
commit | 56601285b24450168e8b1853ae9c8b65f4576cb0 (patch) | |
tree | daf1df0ad8cefef46696d7f9b1990b959d77f198 | |
parent | b698207664e45b9b0bb9944b5c97084dfc593ed6 (diff) | |
download | mrust-56601285b24450168e8b1853ae9c8b65f4576cb0.tar.gz |
Fix pattern handling (not using Parse_Pattern for & patterns, inverted check for & pattern iterate)
-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) ); |