summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-08-29 19:55:49 +0800
committerJohn Hodge <tpg@mutabah.net>2016-08-29 19:55:49 +0800
commit7dd8c0bc78603bb73537571047704889d33f7fbb (patch)
tree45878469c1deb0921894c26a801031c6d19b9811 /src
parent36439817677e14fd95932a5f6e4134799682e35e (diff)
downloadmrust-7dd8c0bc78603bb73537571047704889d33f7fbb.tar.gz
Resolve Absolute - Extern crate enums
Diffstat (limited to 'src')
-rw-r--r--src/resolve/absolute.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/resolve/absolute.cpp b/src/resolve/absolute.cpp
index 5c18aa25..61cbae57 100644
--- a/src/resolve/absolute.cpp
+++ b/src/resolve/absolute.cpp
@@ -754,7 +754,25 @@ namespace {
return Resolve_Absolute_Path_BindUFCS(context, sp, mode, path);
),
(Enum,
- TODO(sp, "Bind via extern enum - " << path);
+ const auto& last_node = path_abs.nodes.back();
+ for( const auto& var : e.m_variants )
+ {
+ if( var.first == last_node.name() ) {
+
+ if( i != path_abs.nodes.size() - 2 ) {
+ ERROR(sp, E0000, "Unexpected enum in path " << path);
+ }
+ // NOTE: Type parameters for enums go after the _variant_
+ if( ! n.args().is_empty() ) {
+ ERROR(sp, E0000, "Type parameters were not expected here (enum params go on the variant)");
+ }
+
+ path.bind( ::AST::PathBinding::make_EnumVar({nullptr, static_cast<unsigned int>(&var - &*e.m_variants.begin())}) );
+ return;
+ }
+ }
+ path = split_into_ufcs_ty(sp, mv$(path), i);
+ return Resolve_Absolute_Path_BindUFCS(context, sp, mode, path);
)
)
}