summaryrefslogtreecommitdiff
path: root/builtins.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtins.c')
-rw-r--r--builtins.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/builtins.c b/builtins.c
index 8215930..7c20b17 100644
--- a/builtins.c
+++ b/builtins.c
@@ -372,18 +372,23 @@ builtinarg(Term *goal, Binding **bindings, Module *module)
Term *term = n->next;
Term *arg = term->next;
+ if(n->tag == VariableTerm || term->tag == VariableTerm)
+ Throw(instantiationerror());
if(n->tag != IntegerTerm)
- return 0;
+ Throw(typeerror(L"integer", n));
+ if(term->tag != CompoundTerm)
+ Throw(typeerror(L"compound", term));
if(n->ival < 0)
Throw(domainerror(L"not_less_than_zero", n));
- if(term->tag != CompoundTerm)
- return 0;
- if(n->ival >= term->arity)
+
+ if(n->ival > term->arity)
return 0;
+ print("Passed checks!\n");
+
int i;
Term *t;
- for(i = 0, t = term->children; i < n->ival; i++, t = t->next);
+ for(i = 1, t = term->children; i < n->ival; i++, t = t->next);
return unify(arg, t, bindings);
}