diff options
author | Peter Mikkelsen <peter@pmikkelsen.com> | 2021-07-07 16:32:02 +0000 |
---|---|---|
committer | Peter Mikkelsen <peter@pmikkelsen.com> | 2021-07-07 16:32:02 +0000 |
commit | 0f958749e189e4dacd7a1f70cfc33460e1228d3b (patch) | |
tree | 5679ea79743a736cc3179c29ea603ae0f39bb51e /builtins.c | |
parent | 73b9bad83e6405809e80809c10c8917f4bd4e341 (diff) |
Make '=..'/2 work according to spec. Introduce types.c for functions which tells us something about term types. Should be used a lot more instead of explicitly looking into terms->tag everywhere
Diffstat (limited to 'builtins.c')
-rw-r--r-- | builtins.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -409,6 +409,23 @@ builtinuniv(Term *goal, Binding **bindings, Module *module) Term *term = goal->children; Term *list = term->next; + if(term->tag == VariableTerm && ispartiallist(list)) + Throw(instantiationerror()); + if(!(ispartiallist(list) || islist(list))) + Throw(typeerror(L"list", list)); + + Term *head = listhead(list); + Term *tail = listtail(list); + + if(term->tag == VariableTerm && head->tag == VariableTerm) + Throw(instantiationerror()); + if(islist(list) && !(head->tag == AtomTerm || head->tag == VariableTerm) && !isemptylist(tail)) + Throw(typeerror(L"atom", head)); + if(islist(list) && head->tag == CompoundTerm && isemptylist(tail)) + Throw(typeerror(L"atomic", head)); + if(term->tag == VariableTerm && isemptylist(list)) + Throw(domainerror(L"non_empty_list", list)); + int len; if(term->tag == VariableTerm){ Rune *name; |