Skip to content

Commit

Permalink
cue: prevent crash in JSON conversion
Browse files Browse the repository at this point in the history
Caught by new test set. Tests will come later.

Change-Id: I33daf892ac90c98284545386d0504f2c87f75f04
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/5820
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
  • Loading branch information
mpvl committed Apr 24, 2020
1 parent dc62e36 commit 12927e8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cue/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -936,8 +936,9 @@ func (v Value) marshalJSON() (b []byte, err error) {
if len(st.comprehensions) > 0 {
// This should always evaluate to incomplete. However, fall back
// to a bad error message, rather than crashing, in case it doesn't.
err, _ := st.comprehensions[0].comp.evalPartial(ctx).(*bottom)
return nil, toMarshalErr(v, err)
if err, ok := st.comprehensions[0].comp.evalPartial(ctx).(*bottom); ok {
return nil, toMarshalErr(v, err)
}
}

if err != nil {
Expand Down

0 comments on commit 12927e8

Please sign in to comment.