proc: return error when assigning between function variables (#2692)

Fixes #2691
This commit is contained in:
Alessandro Arzilli
2021-10-13 17:44:59 +02:00
committed by GitHub
parent 1893c9769b
commit bdcbcc6836
2 changed files with 22 additions and 0 deletions

View File

@ -383,6 +383,13 @@ func (scope *EvalScope) setValue(dstv, srcv *Variable, srcExpr string) error {
real, _ := constant.Float64Val(constant.Real(srcv.Value))
imag, _ := constant.Float64Val(constant.Imag(srcv.Value))
return dstv.writeComplex(real, imag, dstv.RealType.Size())
case reflect.Func:
if dstv.RealType.Size() == 0 {
if dstv.Name != "" {
return fmt.Errorf("can not assign to %s", dstv.Name)
}
return errors.New("can not assign to function expression")
}
}
// nilling nillable variables