Skip to content
Open
Show file tree
Hide file tree
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
15 changes: 11 additions & 4 deletions internal/simplecue/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,13 +518,20 @@ func (g *generator) declareReference(v cue.Value, defV cue.Value) (ast.Type, err
}
}

if v.Kind() == cue.StringKind || v.Kind() == cue.NumberKind {
// concreteV is v if v is a concrete string/number (e.g. #Enum1 & "A" when "A" is not the default),
// or defV when v is abstract but defV is a concrete constraint (e.g. #Enum2 & "C" where "C" is the
// default of #Enum2 — CUE's subsumption collapses the conjunction so v becomes the abstract reference).
concreteV := v
if concreteV.Kind() != cue.StringKind && concreteV.Kind() != cue.NumberKind {
concreteV = defV
}
if concreteV.Kind() == cue.StringKind || concreteV.Kind() == cue.NumberKind {
var referenceValue any
referenceValue, err = v.String()
referenceValue, err = concreteV.String()
if err != nil {
referenceValue, err = v.Int64()
referenceValue, err = concreteV.Int64()
if err != nil {
return ast.Type{}, errorWithCueRef(v, "%v", err.Error())
return ast.Type{}, errorWithCueRef(concreteV, "%v", err.Error())
}
}

Expand Down
Loading
Loading