diff options
author | John Hodge <tpg@mutabah.net> | 2016-10-25 11:37:50 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-10-25 11:37:50 +0800 |
commit | 812f5625c41bc064755cdc1bf030901b10a6091f (patch) | |
tree | 249c009cf92f65372c4b06167c2fa39bf0a3f516 /src/resolve/use.cpp | |
parent | 7296a4de682f949d92d43b61b994fd4f1796df53 (diff) | |
download | mrust-812f5625c41bc064755cdc1bf030901b10a6091f.tar.gz |
Resolve - Fix behavior of `super` in anon modules
Diffstat (limited to 'src/resolve/use.cpp')
-rw-r--r-- | src/resolve/use.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
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; |