From 1fbd12d2954f22b96f8da0ae9bc3e0b091d9a838 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Tue, 22 Aug 2017 19:46:41 +0800 Subject: Expand - allow #![no_std] or #![no_core] to be repeated --- src/expand/std_prelude.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/expand/std_prelude.cpp b/src/expand/std_prelude.cpp index 16c4ce90..e12a441c 100644 --- a/src/expand/std_prelude.cpp +++ b/src/expand/std_prelude.cpp @@ -8,9 +8,9 @@ class Decorator_NoStd: { public: AttrStage stage() const override { return AttrStage::Pre; } - + void handle(const Span& sp, const AST::MetaItem& mi, AST::Crate& crate) const override { - if( crate.m_load_std != AST::Crate::LOAD_STD ) { + if( crate.m_load_std != AST::Crate::LOAD_STD && crate.m_load_std != AST::Crate::LOAD_CORE ) { ERROR(sp, E0000, "Invalid use of #![no_std] with itself or #![no_core]"); } crate.m_load_std = AST::Crate::LOAD_CORE; @@ -23,7 +23,7 @@ public: AttrStage stage() const override { return AttrStage::Pre; } void handle(const Span& sp, const AST::MetaItem& mi, AST::Crate& crate) const override { - if( crate.m_load_std != AST::Crate::LOAD_STD ) { + if( crate.m_load_std != AST::Crate::LOAD_STD && crate.m_load_std != AST::Crate::LOAD_NONE ) { ERROR(sp, E0000, "Invalid use of #![no_core] with itself or #![no_std]"); } crate.m_load_std = AST::Crate::LOAD_NONE; -- cgit v1.2.3 From ae2c2e15bea28bd03efd70060fcb4c49e43477f6 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Tue, 22 Aug 2017 21:21:16 +0800 Subject: Expand - Handle windows paths in `include!` --- src/expand/include.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/expand/include.cpp b/src/expand/include.cpp index a6eb9fe1..22b7d1a9 100644 --- a/src/expand/include.cpp +++ b/src/expand/include.cpp @@ -30,18 +30,19 @@ namespace { ::std::string get_path_relative_to(const ::std::string& base_path, ::std::string path) { - if( path[0] == '/' ) { + DEBUG(base_path << ", " << path); + if( path[0] == '/' || path[0] == '\\' ) { return path; } else if( base_path.size() == 0 ) { return path; } - else if( base_path[base_path.size()-1] == '/' ) { + else if( base_path.back() == '/' || base_path.back() == '\\' ) { return base_path + path; } else { - auto slash = base_path.find_last_of('/'); + auto slash = ::std::min( base_path.find_last_of('/'), base_path.find_last_of('\\') ); if( slash == ::std::string::npos ) { return path; @@ -75,7 +76,13 @@ class CIncludeExpander: ::std::string file_path = get_path_relative_to(mod.m_file_info.path, mv$(path)); - return box$( Lexer(file_path) ); + try { + return box$( Lexer(file_path) ); + } + catch(::std::runtime_error& e) + { + ERROR(sp, E0000, e.what()); + } } }; -- cgit v1.2.3 From 251e49aef76e46af5005978ac25650aab4f94313 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Tue, 22 Aug 2017 21:21:44 +0800 Subject: Resolve Use - (minor) Diagnostics fix when module cannot be found --- src/resolve/use.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/resolve/use.cpp b/src/resolve/use.cpp index 5e1fce6d..9c27711d 100644 --- a/src/resolve/use.cpp +++ b/src/resolve/use.cpp @@ -688,7 +688,10 @@ namespace { auto b = Resolve_Use_GetBinding_Mod(span, crate, *mod, nodes[i].name(), parent_modules, Lookup::Type); TU_MATCH_DEF(::AST::PathBinding, (b), (e), ( - ERROR(span, E0000, "Unexpected item type in import"); + ERROR(span, E0000, "Unexpected item type " << b.tag_str() << " in import of " << path); + ), + (Unbound, + ERROR(span, E0000, "Cannot find component " << i << " of " << path); ), (Crate, // TODO: Mangle the original path (or return a new path somehow) -- cgit v1.2.3 From 0eb50366561cd91bed78b3e721e6ea94dbecded1 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Tue, 22 Aug 2017 21:22:09 +0800 Subject: Typecheck/MIR - Some missing EAT invocations --- src/hir_typeck/expr_check.cpp | 12 ++++++++++-- src/mir/helpers.cpp | 7 +++++-- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/hir_typeck/expr_check.cpp b/src/hir_typeck/expr_check.cpp index a5d34186..14cc488c 100644 --- a/src/hir_typeck/expr_check.cpp +++ b/src/hir_typeck/expr_check.cpp @@ -965,8 +965,16 @@ namespace { (Constant, auto cb = monomorphise_type_get_cb(sp, &*e.type, &e.trait.m_params, nullptr); ::HIR::TypeRef tmp; - const auto& ty = ( monomorphise_type_needed(ie.m_type) ? tmp = monomorphise_type_with(sp, ie.m_type, cb) : ie.m_type ); - check_types_equal(sp, node.m_res_type, ty); + const ::HIR::TypeRef* typ; + if(monomorphise_type_needed(ie.m_type)) { + tmp = monomorphise_type_with(sp, ie.m_type, cb); + m_resolve.expand_associated_types(sp, tmp); + typ = &tmp; + } + else { + typ = &ie.m_type; + } + check_types_equal(sp, node.m_res_type, *typ); ), (Static, TODO(sp, "Monomorpise associated static type - " << ie.m_type); diff --git a/src/mir/helpers.cpp b/src/mir/helpers.cpp index b90f3cf6..10c9c780 100644 --- a/src/mir/helpers.cpp +++ b/src/mir/helpers.cpp @@ -287,8 +287,11 @@ const ::HIR::TypeRef& MIR::TypeResolve::get_param_type(::HIR::TypeRef& tmp, cons auto v = m_resolve.get_value(this->sp, e.p, p, /*signature_only=*/true); if( const auto* ve = v.opt_Constant() ) { const auto& ty = (*ve)->m_type; - if( monomorphise_type_needed(ty) ) - MIR_TODO(*this, "get_const_type - Monomorphise type " << ty); + if( monomorphise_type_needed(ty) ) { + auto rv = p.monomorph(this->sp, ty); + m_resolve.expand_associated_types(this->sp, rv); + return rv; + } else return ty.clone(); } -- cgit v1.2.3