From 812f5625c41bc064755cdc1bf030901b10a6091f Mon Sep 17 00:00:00 2001 From: John Hodge Date: Tue, 25 Oct 2016 11:37:50 +0800 Subject: Resolve - Fix behavior of `super` in anon modules --- src/resolve/use.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/resolve/use.cpp') diff --git a/src/resolve/use.cpp b/src/resolve/use.cpp index 0db58a51..ad668b40 100644 --- a/src/resolve/use.cpp +++ b/src/resolve/use.cpp @@ -67,7 +67,12 @@ void Resolve_Use(::AST::Crate& crate) if( e.count > base_path.nodes().size() ) { ERROR(span, E0000, "Too many `super` components"); } - for( unsigned int i = 0; i < base_path.nodes().size() - e.count; i ++ ) + // TODO: Do this in a cleaner manner. + unsigned int n_anon = 0; + // Skip any anon modules in the way (i.e. if the current module is an anon, go to the parent) + while( base_path.nodes().size() > n_anon && base_path.nodes()[ base_path.nodes().size()-1-n_anon ].name()[0] == '#' ) + n_anon ++; + for( unsigned int i = 0; i < base_path.nodes().size() - e.count - n_anon; i ++ ) np.nodes().push_back( base_path.nodes()[i] ); np += path; return np; -- cgit v1.2.3