aboutsummaryrefslogtreecommitdiffstats
path: root/typing.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-03-07 01:23:05 +0000
committerDavid Robillard <d@drobilla.net>2009-03-07 01:23:05 +0000
commit1865e80acca50f58cae41e8ed4e86a9c67e3a1ef (patch)
tree0ccc71383916b260bd8463d098b773407da2c463 /typing.cpp
parenta7e747b45b0ff3f9e106182e6a357d0b261255a5 (diff)
downloadresp-1865e80acca50f58cae41e8ed4e86a9c67e3a1ef.tar.gz
resp-1865e80acca50f58cae41e8ed4e86a9c67e3a1ef.tar.bz2
resp-1865e80acca50f58cae41e8ed4e86a9c67e3a1ef.zip
Typing improvements.
More location information. git-svn-id: http://svn.drobilla.net/resp/tuplr@67 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'typing.cpp')
-rw-r--r--typing.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/typing.cpp b/typing.cpp
index 389edf0..c9febda 100644
--- a/typing.cpp
+++ b/typing.cpp
@@ -134,6 +134,7 @@ ASTPrimitive::constrain(TEnv& tenv) const
void
ASTConsCall::constrain(TEnv& tenv) const
{
+ if (size() != 3) throw Error("`cons' requires exactly 2 arguments", loc);
AType* t = new AType(ASTTuple(tenv.penv.sym("Pair"), 0), loc);
for (size_t i = 1; i < size(); ++i) {
at(i)->constrain(tenv);
@@ -145,9 +146,10 @@ ASTConsCall::constrain(TEnv& tenv) const
void
ASTCarCall::constrain(TEnv& tenv) const
{
+ if (size() != 2) throw Error("`car' requires exactly 1 argument", loc);
at(1)->constrain(tenv);
AType* ct = tenv.var(loc);
- AType* tt = new AType(ASTTuple(tenv.penv.sym("Pair"), ct, tenv.var(at(2)->loc), 0), loc);
+ AType* tt = new AType(ASTTuple(tenv.penv.sym("Pair"), ct, tenv.var(), 0), loc);
tenv.constrain(at(1), tt);
tenv.constrain(this, ct);
}
@@ -155,9 +157,10 @@ ASTCarCall::constrain(TEnv& tenv) const
void
ASTCdrCall::constrain(TEnv& tenv) const
{
+ if (size() != 2) throw Error("`cdr' requires exactly 1 argument", loc);
at(1)->constrain(tenv);
AType* ct = tenv.var(loc);
- AType* tt = new AType(ASTTuple(tenv.penv.sym("Pair"), tenv.var(at(1)->loc), ct, 0), loc);
+ AType* tt = new AType(ASTTuple(tenv.penv.sym("Pair"), tenv.var(), ct, 0), loc);
tenv.constrain(at(1), tt);
tenv.constrain(this, ct);
}