From 7dd8c0bc78603bb73537571047704889d33f7fbb Mon Sep 17 00:00:00 2001 From: John Hodge Date: Mon, 29 Aug 2016 19:55:49 +0800 Subject: Resolve Absolute - Extern crate enums --- src/resolve/absolute.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src') 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(&var - &*e.m_variants.begin())}) ); + return; + } + } + path = split_into_ufcs_ty(sp, mv$(path), i); + return Resolve_Absolute_Path_BindUFCS(context, sp, mode, path); ) ) } -- cgit v1.2.3