Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions conf/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,22 @@ func (c *Config) WithEnv(env any) {
}

func (c *Config) ConstExpr(name string) {
// Check if the function is defined via expr.Function first.
if fn, ok := c.Functions[name]; ok {
if fn.Func != nil {
c.ConstFns[name] = reflect.ValueOf(fn.Func)
return
}
if fn.Fast != nil {
c.ConstFns[name] = reflect.ValueOf(fn.Fast)
return
}
if fn.Safe != nil {
c.ConstFns[name] = reflect.ValueOf(fn.Safe)
return
}
panic(fmt.Errorf("const expression %q must have a function implementation", name))
}
if c.EnvObject == nil {
panic("no environment is specified for ConstExpr()")
}
Expand Down
Loading