diff options
author | John Hodge <tpg@mutabah.net> | 2016-05-01 14:22:52 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-05-01 14:22:52 +0800 |
commit | 258f1d3894a8261e2bf3d6528093c152ad53c4b0 (patch) | |
tree | 1737be382ecfed4e782d27897055633789d4939a /src/resolve | |
parent | b613f53aecc651ca36b550345175554d2d2def8d (diff) | |
download | mrust-258f1d3894a8261e2bf3d6528093c152ad53c4b0.tar.gz |
AST - Remove Expr from patterns (replace with local Value type)
Diffstat (limited to 'src/resolve')
-rw-r--r-- | src/resolve/absolute.cpp | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/resolve/absolute.cpp b/src/resolve/absolute.cpp index de555c37..7d521686 100644 --- a/src/resolve/absolute.cpp +++ b/src/resolve/absolute.cpp @@ -351,6 +351,19 @@ void Resolve_Absolute_Generic(const Context& context, ::AST::GenericParams& para } } +// Locals shouldn't be possible, as they'd end up as MaybeBind. Will assert the path class. +void Resolve_Absolute_PatternValue(const Context& context, ::AST::Pattern::Value& val) +{ + TU_MATCH(::AST::Pattern::Value, (val), (e), + (Invalid, ), + (Integer, ), + (String, ), + (Named, + assert( ! e.is_trivial() ); + Resolve_Absolute_Path(context, Span(), true, e); + ) + ) +} void Resolve_Absolute_Pattern(Context& context, bool allow_refutable, ::AST::Pattern& pat) { if( pat.binding() != "" ) { @@ -361,7 +374,12 @@ void Resolve_Absolute_Pattern(Context& context, bool allow_refutable, ::AST::Pa TU_MATCH( ::AST::Pattern::Data, (pat.data()), (e), (MaybeBind, - BUG(Span(), "Resolve_Absolute_Pattern - Encountered MaybeBind"); + if( allow_refutable ) { + TODO(Span(), "Resolve_Absolute_Pattern - Encountered MaybeBind in refutable context"); + } + else { + TODO(Span(), "Resolve_Absolute_Pattern - Encountered MaybeBind in irrefutable context - replace with binding"); + } ), (Macro, BUG(Span(), "Resolve_Absolute_Pattern - Encountered Macro"); @@ -378,10 +396,8 @@ void Resolve_Absolute_Pattern(Context& context, bool allow_refutable, ::AST::Pa (Value, if( ! allow_refutable ) BUG(Span(), "Resolve_Absolute_Pattern - Enountered refutable pattern where only irrefutable allowed"); - // TODO: Value patterns should be resolved with a different context (disallowing locals) - Resolve_Absolute_Expr(context, *e.start); - if( e.end ) - Resolve_Absolute_Expr(context, *e.end); + Resolve_Absolute_PatternValue(context, e.start); + Resolve_Absolute_PatternValue(context, e.end); ), (Tuple, for(auto& sp : e.sub_patterns) |