aboutsummaryrefslogtreecommitdiffstats
path: root/src/unify.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-10-15 19:34:01 +0000
committerDavid Robillard <d@drobilla.net>2009-10-15 19:34:01 +0000
commit6d4564794d2257ac9e9f1fb674914c5abaed3951 (patch)
treeca50b51e33e2d4e7737eb8e2da828daef6b41c6d /src/unify.cpp
parentc139e62f1fa1341eaa9c6f7b7d8e54601721a329 (diff)
downloadresp-6d4564794d2257ac9e9f1fb674914c5abaed3951.tar.gz
resp-6d4564794d2257ac9e9f1fb674914c5abaed3951.tar.bz2
resp-6d4564794d2257ac9e9f1fb674914c5abaed3951.zip
Remove some use of ATuple::size().
git-svn-id: http://svn.drobilla.net/resp/tuplr@230 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src/unify.cpp')
-rw-r--r--src/unify.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/unify.cpp b/src/unify.cpp
index 5284bea..92957c0 100644
--- a/src/unify.cpp
+++ b/src/unify.cpp
@@ -32,7 +32,6 @@ TEnv::buildSubst(AType* genericT, const AType& argsT)
// Build substitution to apply to generic type
const ATuple* genericProtT = (*(genericT->begin() + 1))->as<const ATuple*>();
- assert(argsT.size() == genericProtT->size());
ATuple::const_iterator g = genericProtT->begin();
AType::const_iterator a = argsT.begin();
for (; a != argsT.end(); ++a, ++g) {
@@ -40,7 +39,6 @@ TEnv::buildSubst(AType* genericT, const AType& argsT)
AType* callArgT = (*a)->to<AType*>();
if (callArgT->kind == AType::EXPR) {
assert(genericArgT->kind == AType::EXPR);
- assert(callArgT->size() == genericArgT->size());
ATuple::const_iterator gi = genericArgT->begin();
ATuple::const_iterator ci = callArgT->begin();
for (; gi != genericArgT->end(); ++gi, ++ci) {
@@ -125,18 +123,18 @@ unify(const Constraints& constraints)
} else if (t->kind == AType::VAR && !s->contains(t)) {
cp.replace(t, s);
return Subst::compose(unify(cp), Subst(t, s));
- } else if (s->kind == AType::EXPR && s->kind == t->kind && s->size() == t->size()) {
+ } else if (s->kind == AType::EXPR && t->kind == AType::EXPR) {
AType::iterator si = s->begin() + 1;
AType::iterator ti = t->begin() + 1;
- for (; si != s->end(); ++si, ++ti) {
+ for (; si != s->end() && ti != t->end(); ++si, ++ti) {
AType* st = (*si)->to<AType*>();
AType* tt = (*ti)->to<AType*>();
assert(st && tt);
cp.push_back(Constraint(st, tt, st->loc));
}
- return unify(cp);
- } else {
- throw Error(s->loc ? s->loc : t->loc,
- (format("type is `%1%' but should be `%2%'") % s->str() % t->str()).str());
+ if (si == s->end() && ti == t->end())
+ return unify(cp);
}
+ throw Error(s->loc ? s->loc : t->loc,
+ (format("type is `%1%' but should be `%2%'") % s->str() % t->str()).str());
}