operator-assign.go: improvements that allow to define function aliases (TODO: maybe *funcDefFunctor else-if section can be removed
This commit is contained in:
parent
71ab417a56
commit
3a30d890c6
@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com).
|
||||
// All rights reserved.
|
||||
// All rights reserightChilded.
|
||||
|
||||
// operator-assign.go
|
||||
package expr
|
||||
@ -27,11 +27,17 @@ func evalAssign(ctx ExprContext, self *term) (v any, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
if v, err = self.children[1].compute(ctx); err == nil {
|
||||
if functor, ok := v.(Functor); ok {
|
||||
var minArgs, maxArgs int = 0, 0
|
||||
rightChild := self.children[1]
|
||||
|
||||
if funcDef, ok := functor.(*funcDefFunctor); ok {
|
||||
if v, err = rightChild.compute(ctx); err == nil {
|
||||
if functor, ok := v.(Functor); ok {
|
||||
var minArgs, maxArgs int = 0, -1
|
||||
|
||||
funcName := rightChild.source()
|
||||
if info, exists := ctx.GetFuncInfo(funcName); exists {
|
||||
minArgs = info.MinArgs()
|
||||
maxArgs = info.MaxArgs()
|
||||
} else if funcDef, ok := functor.(*funcDefFunctor); ok {
|
||||
l := len(funcDef.params)
|
||||
minArgs = l
|
||||
maxArgs = l
|
||||
|
Loading…
Reference in New Issue
Block a user