diff options
author | John Hodge <tpg@ucc.asn.au> | 2017-08-27 18:45:33 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2017-08-27 18:45:33 +0800 |
commit | 1a1975dd129f00f94c67bf6d1a0b14b3a36c5471 (patch) | |
tree | b112e223ee66702b3cb1140b817b73b247ad752a | |
parent | 1ea188d13b8ea8d977c82ff0060b6420d8c81ffc (diff) | |
download | mrust-1a1975dd129f00f94c67bf6d1a0b14b3a36c5471.tar.gz |
Resolve Use - Do parent search on Relative paths
-rw-r--r-- | src/resolve/use.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/resolve/use.cpp b/src/resolve/use.cpp index 5fd01214..c4d32a6f 100644 --- a/src/resolve/use.cpp +++ b/src/resolve/use.cpp @@ -47,9 +47,22 @@ void Resolve_Use(::AST::Crate& crate) BUG(span, "UFCS path class in use statement"); ), (Relative, - return base_path + path; + // How can this happen? + DEBUG("Relative " << path); + // EVIL HACK: If the current module is an anon module, refer to the parent + if( base_path.nodes().size() > 0 && base_path.nodes().back().name()[0] == '#' ) { + AST::Path np("", {}); + for( unsigned int i = 0; i < base_path.nodes().size() - 1; i ++ ) + np.nodes().push_back( base_path.nodes()[i] ); + np += path; + return np; + } + else { + return base_path + path; + } ), (Self, + DEBUG("Self " << path); // EVIL HACK: If the current module is an anon module, refer to the parent if( base_path.nodes().size() > 0 && base_path.nodes().back().name()[0] == '#' ) { AST::Path np("", {}); @@ -63,6 +76,7 @@ void Resolve_Use(::AST::Crate& crate) } ), (Super, + DEBUG("Super " << path); assert(e.count >= 1); AST::Path np("", {}); if( e.count > base_path.nodes().size() ) { @@ -79,6 +93,7 @@ void Resolve_Use(::AST::Crate& crate) return np; ), (Absolute, + DEBUG("Absolute " << path); // Leave as is return path; ) |