summaryrefslogtreecommitdiff
path: root/src/hir_conv/bind.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-05-29 21:41:05 +0800
committerJohn Hodge <tpg@mutabah.net>2016-05-29 21:41:05 +0800
commit73bcd2fb0bda8f939a6c1385b419a67ad8eeef2c (patch)
tree5c397d572cd5ddfb0a7d55c35ff430f73e6073a5 /src/hir_conv/bind.cpp
parentfd9b01b2d8b1efb4f7f95a72af4eeff2fae2a576 (diff)
downloadmrust-73bcd2fb0bda8f939a6c1385b419a67ad8eeef2c.tar.gz
HIR Typecheck - Expression inference coming along
Diffstat (limited to 'src/hir_conv/bind.cpp')
-rw-r--r--src/hir_conv/bind.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/hir_conv/bind.cpp b/src/hir_conv/bind.cpp
index 4b4acf4d..948a3d75 100644
--- a/src/hir_conv/bind.cpp
+++ b/src/hir_conv/bind.cpp
@@ -83,6 +83,16 @@ namespace {
throw "";
}
+ void fix_type_params(const Span& sp, const ::HIR::GenericParams& params_def, ::HIR::PathParams& params)
+ {
+ if( params.m_types.size() == 0 ) {
+ params.m_types.resize( params_def.m_types.size() );
+ }
+ if( params.m_types.size() != params_def.m_types.size() ) {
+ ERROR(sp, E0000, "Incorrect parameter count, expected " << params_def.m_types.size() << ", got " << params.m_types.size());
+ }
+ }
+
class Visitor:
public ::HIR::Visitor
{
@@ -111,6 +121,8 @@ namespace {
else {
ERROR(sp, E0000, "Struct tuple pattern on non-tuple struct " << e.path);
}
+
+ fix_type_params(sp, str.m_params, e.path.m_params);
e.binding = &str;
),
(Struct,
@@ -121,6 +133,7 @@ namespace {
else {
ERROR(sp, E0000, "Struct pattern on field-less struct " << e.path);
}
+ fix_type_params(sp, str.m_params, e.path.m_params);
e.binding = &str;
),
(EnumTuple,
@@ -137,6 +150,7 @@ namespace {
else {
ERROR(sp, E0000, "Enum tuple pattern on non-tuple variant " << e.path);
}
+ fix_type_params(sp, enm.m_params, e.path.m_params);
e.binding_ptr = &enm;
e.binding_idx = idx;
),
@@ -154,6 +168,7 @@ namespace {
else {
ERROR(sp, E0000, "Enum tuple pattern on non-tuple variant " << e.path);
}
+ fix_type_params(sp, enm.m_params, e.path.m_params);
e.binding_ptr = &enm;
e.binding_idx = idx;
)