Skip to content

Commit a387e53

Browse files
committed
add error check
cleanup
1 parent 09a4686 commit a387e53

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

internal/simplecue/generator.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -730,15 +730,16 @@ func (g *generator) declareStringConstraints(v cue.Value) ([]ast.TypeConstraint,
730730

731731
for i := 0; i < len(typeAndConstraints); i++ {
732732
andExpr := typeAndConstraints[i]
733+
if err := andExpr.Err(); err != nil {
734+
return nil, errorWithCueRef(v, "error while parsing constraints: %v", err)
735+
}
736+
733737
op, args := andExpr.Expr()
734738

735739
switch op {
736740
case cue.SelectorOp:
737741
scope, refPath := andExpr.ReferencePath()
738-
if refPath.String() != "" {
739-
typeAndConstraints = append(typeAndConstraints, scope.LookupPath(refPath))
740-
}
741-
continue
742+
typeAndConstraints = append(typeAndConstraints, scope.LookupPath(refPath))
742743
case cue.CallOp:
743744
// TODO: support more constraints?
744745
switch fmt.Sprint(args[0]) {

0 commit comments

Comments
 (0)