summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/expand/include.cpp15
-rw-r--r--src/expand/std_prelude.cpp6
-rw-r--r--src/hir_typeck/expr_check.cpp12
-rw-r--r--src/mir/helpers.cpp7
-rw-r--r--src/resolve/use.cpp5
5 files changed, 33 insertions, 12 deletions
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());
+ }
}
};
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;
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();
}
diff --git a/src/resolve/use.cpp b/src/resolve/use.cpp
index be0c2ab8..5fd01214 100644
--- a/src/resolve/use.cpp
+++ b/src/resolve/use.cpp
@@ -696,7 +696,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)