From 45b8b8d09c652af9850d3eb49b1a23e551e93fbf Mon Sep 17 00:00:00 2001 From: Lukas Jarosch Date: Wed, 1 May 2024 15:07:01 +0200 Subject: [PATCH] feat: `evalCall` now also supports `data.Value` parameters --- expression/exec.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/expression/exec.go b/expression/exec.go index d655ac7..bfab8b7 100644 --- a/expression/exec.go +++ b/expression/exec.go @@ -305,7 +305,19 @@ func (s *state) evalCall(call *CallNode) (reflect.Value, error) { // except in cases where argType is interface{} if argType.Kind() != reflect.Interface { if argType.Kind() != argValue.Kind() { - s.errorf("%s expected %s got %s", ErrIncompatibleArgType, argType.Kind(), argValue.Kind()) + + // it may very well be that, at this point, the argValue is a `data.Value` + // because it is the result of an expression which was executed prior to this one + dataValue, ok := argValue.Interface().(data.Value) + if !ok { + s.errorf("%s expected %s; got %s", ErrIncompatibleArgType, argType.Kind(), argValue.Kind()) + } + if reflect.TypeOf(dataValue.Raw) == argType { + argValue = reflect.ValueOf(dataValue.Raw) + } else { + s.errorf("%s (data.Value) expected %s; got %s", ErrIncompatibleArgType, argType.Kind(), argValue.Kind()) + } + } }