Skip to content

Commit 7c8fa05

Browse files
authored
Merge pull request #801 from wader/interp-synthetic-raw-inf-recur
interp: Fix infinite recursion when casting synthetic raw value into …
2 parents bed89f7 + 29e7541 commit 7c8fa05

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

internal/gojqex/totype.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ func ToGoJQValueFn(v any, valueFn func(v any) (any, error)) (any, error) {
8989
vvs[k] = v
9090
}
9191
return vvs, nil
92+
case error:
93+
return nil, vv
9294
default:
9395
nv, err := valueFn(vv)
9496
if err != nil {

pkg/interp/decode.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -634,12 +634,15 @@ func (v decodeValue) JQValueToGoJQEx(optsFn func() (*Options, error)) any {
634634
return v.JQValueToGoJQ()
635635
}
636636

637-
bv, err := v.decodeValueBase.ToBinary()
638-
if err != nil {
639-
return err
637+
if s, ok := v.dv.V.(scalar.Scalarable); ok && !s.ScalarFlags().IsSynthetic() {
638+
bv, err := v.ToBinary()
639+
if err != nil {
640+
return err
641+
}
642+
return bv.JQValueToGoJQEx(optsFn)
640643
}
641644

642-
return bv.JQValueToGoJQEx(optsFn)
645+
return v.JQValueToGoJQ()
643646

644647
}
645648

0 commit comments

Comments
 (0)