diff options
Diffstat (limited to 'typing.cpp')
-rw-r--r-- | typing.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -149,9 +149,9 @@ ACall::constrain(TEnv& tenv, Constraints& c) const void ADefinition::constrain(TEnv& tenv, Constraints& c) const { - if (size() != 3) throw Error("`def' requires exactly 2 arguments", loc); + THROW_IF(size() != 3, "`def' requires exactly 2 arguments", loc); const ASymbol* sym = this->sym(); - if (!sym) throw Error("`def' has no symbol", loc); + THROW_IF(!sym, "`def' has no symbol", loc) AType* tvar = tenv.var(at(2)); tenv.def(sym, make_pair(at(2), tvar)); @@ -162,8 +162,8 @@ ADefinition::constrain(TEnv& tenv, Constraints& c) const void AIf::constrain(TEnv& tenv, Constraints& c) const { - if (size() < 3) throw Error("`if' requires exactly 3 arguments", loc); - if (size() % 2 != 0) throw Error("`if' missing final else clause", loc); + THROW_IF(size() < 4, "`if' requires at least 3 argumentsz", loc); + THROW_IF(size() % 2 != 0, "`if' missing final else clause", loc) for (size_t i = 1; i < size(); ++i) at(i)->constrain(tenv, c); AType* retT = tenv.var(this); @@ -230,7 +230,7 @@ APrimitive::constrain(TEnv& tenv, Constraints& c) const void AConsCall::constrain(TEnv& tenv, Constraints& c) const { - if (size() != 3) throw Error("`cons' requires exactly 2 arguments", loc); + THROW_IF(size() != 3, "`cons' requires exactly 2 arguments", loc) AType* t = new AType(loc, tenv.penv.sym("Pair"), 0); for (size_t i = 1; i < size(); ++i) { at(i)->constrain(tenv, c); @@ -242,7 +242,7 @@ AConsCall::constrain(TEnv& tenv, Constraints& c) const void ACarCall::constrain(TEnv& tenv, Constraints& c) const { - if (size() != 2) throw Error("`car' requires exactly 1 argument", loc); + THROW_IF(size() != 2, "`car' requires exactly 1 argument", loc) at(1)->constrain(tenv, c); AType* carT = tenv.var(this); AType* pairT = new AType(at(1)->loc, tenv.penv.sym("Pair"), carT, tenv.var(), 0); @@ -253,7 +253,7 @@ ACarCall::constrain(TEnv& tenv, Constraints& c) const void ACdrCall::constrain(TEnv& tenv, Constraints& c) const { - if (size() != 2) throw Error("`cdr' requires exactly 1 argument", loc); + THROW_IF(size() != 2, "`cdr' requires exactly 1 argument", loc) at(1)->constrain(tenv, c); AType* cdrT = tenv.var(this); AType* pairT = new AType(at(1)->loc, tenv.penv.sym("Pair"), tenv.var(), cdrT, 0); |