-
-
Notifications
You must be signed in to change notification settings - Fork 475
Closed
Description
Here`s the demo:
https://go.dev/play/p/3nmVM4gi7AZ
package main
import (
"fmt"
"time"
"github.com/expr-lang/expr"
)
func main() {
env := map[string]any{
// no error return
"foo": func(string, ...string) time.Time { return time.Time{} },
"str": "",
}
prog, err := expr.Compile(`foo(str)`, expr.Env(env))
if err != nil {
panic(err)
}
// define changed
env["foo"] = func(s string, layout ...string) (time.Time, error) {
fmt.Println("called")
return time.Now(), nil
}
_, err = expr.Run(prog, env)
if err == nil {
panic(fmt.Sprintf("expected error for change the function signature.but no error return."))
}
}If the signature of the foo function is inconsistent with the compile-time version, can it still execute normally? Is this expected behavior or a bug?
Raw Chinese: 如果 foo 函数的签名与编译时不一致,依然能够正常执行。这是预期内的么?还是一个 Bug ?
Metadata
Metadata
Assignees
Labels
No labels