this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

internal/core/adt: fix disjunctions in data mode

The toDataAll path is currently not used, but will
be used in the upcoming matchN builtin.

In data mode, defaults of disjunctons should be taken
and a non-ambiguous default should consequently be
converted to data also.

This will be tested as part of the matchN builtin.

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: I40c1fed6c6c2284c750c3f9115a8ea6456bcc37a
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1199550
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>

+12 -2
+12 -2
internal/core/adt/composite.go
··· 760 760 // to avoid issues with the closedness algorithm down the line. 761 761 case *Disjunction: 762 762 d := *x 763 - d.Values = make([]Value, len(x.Values)) 764 - for i, v := range x.Values { 763 + values := x.Values 764 + // Data mode involves taking default values and if there is an 765 + // unambiguous default value, we should convert that to data as well. 766 + switch x.NumDefaults { 767 + case 0: 768 + case 1: 769 + return toDataAll(ctx, values[0]) 770 + default: 771 + values = values[:x.NumDefaults] 772 + } 773 + d.Values = make([]Value, len(values)) 774 + for i, v := range values { 765 775 switch x := v.(type) { 766 776 case *Vertex: 767 777 d.Values[i] = x.ToDataAll(ctx)