diff options
author | John Hodge (sonata) <tpg@mutabah.net> | 2015-01-20 22:24:46 +0800 |
---|---|---|
committer | John Hodge (sonata) <tpg@mutabah.net> | 2015-01-20 22:24:46 +0800 |
commit | 15284f127f4c622bf4d67d8d8c44e1799f84e7cb (patch) | |
tree | 4b85f478b9f840eeba2bfada5d53d8c7d70b6aef /src/types.cpp | |
parent | 2306ea6076531132e990d038bdf759b71d9654db (diff) | |
download | mrust-15284f127f4c622bf4d67d8d8c44e1799f84e7cb.tar.gz |
Type resolution coming along, need to add 'self' to the local variable table
Diffstat (limited to 'src/types.cpp')
-rw-r--r-- | src/types.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/types.cpp b/src/types.cpp index d0bd0cc3..384c0e6e 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -34,20 +34,26 @@ void TypeRef::merge_with(const TypeRef& other) if( m_class == TypeRef::ANY ) { *this = other; + return; } if( m_class != other.m_class ) throw ::std::runtime_error("TypeRef::merge_with - Types not compatible"); + if( is_concrete() && other.is_concrete() ) + { + if( *this != other ) + throw ::std::runtime_error("TypeRef::merge_with - Types not compatible"); + return; + } + + switch(m_class) { case TypeRef::ANY: - break; case TypeRef::UNIT: case TypeRef::PRIMITIVE: - if( other != *this && other.is_concrete() ) - throw ::std::runtime_error("TypeRef::merge_with - Types not compatible"); - break; + throw ::std::runtime_error("TypeRef::merge_with - Reached concrete/wildcard"); case TypeRef::TUPLE: // Other is known not to be wildcard, and is also a tuple, so it must be the same size if( m_inner_types.size() != other.m_inner_types.size() ) @@ -144,6 +150,7 @@ bool TypeRef::operator==(const TypeRef& x) const } return true; case TypeRef::GENERIC: + DEBUG(*this << " == " << x); throw ::std::runtime_error("BUGCHECK - Can't compare generic type"); case TypeRef::PATH: return m_path == x.m_path; |