diff options
author | David Robillard <d@drobilla.net> | 2009-03-07 01:23:05 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-03-07 01:23:05 +0000 |
commit | 1865e80acca50f58cae41e8ed4e86a9c67e3a1ef (patch) | |
tree | 0ccc71383916b260bd8463d098b773407da2c463 /typing.cpp | |
parent | a7e747b45b0ff3f9e106182e6a357d0b261255a5 (diff) | |
download | resp-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.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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); } |