the function call procedure now check the number of actual parameters against the numer of formal parameters

This commit is contained in:
2024-05-04 22:35:03 +02:00
parent 0fdd51049d
commit 1d8569d3a9
5 changed files with 32 additions and 8 deletions
+8 -1
View File
@@ -29,7 +29,14 @@ func evalAssign(ctx ExprContext, self *term) (v any, err error) {
if v, err = self.children[1].compute(ctx); err == nil {
if functor, ok := v.(Functor); ok {
ctx.RegisterFunc(leftTerm.source(), functor, 0, -1)
var minArgs, maxArgs int = 0, 0
if funcDef, ok := functor.(*funcDefFunctor); ok {
l := len(funcDef.params)
minArgs = l
maxArgs = l
}
ctx.RegisterFunc(leftTerm.source(), functor, minArgs, maxArgs)
} else {
ctx.setVar(leftTerm.source(), v)
}