Skip to content

Commit

Permalink
fix: labelled inputs sometimes validated against for functions (#1291)
Browse files Browse the repository at this point in the history
  • Loading branch information
davenewza authored Nov 9, 2023
1 parent a3406f1 commit 7d63db1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
Binary file removed schema/__debug_bin947378542
Binary file not shown.
16 changes: 5 additions & 11 deletions schema/validation/unused_inputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,12 @@ func UnusedInputRule(_ []*parser.AST, errs *errorhandling.ValidationErrors) Visi
unused := map[string]*parser.NameNode{}

return Visitor{
EnterModelSection: func(n *parser.ModelSectionNode) {
isAction = len(n.Actions) > 0
},
LeaveModelSection: func(n *parser.ModelSectionNode) {
isAction = false
EnterAction: func(n *parser.ActionNode) {
unused = map[string]*parser.NameNode{}
isAction = true
},
LeaveAction: func(n *parser.ActionNode) {
if !isAction {
return
}
isAction = false

// if the action is implemented as a function, then we don't know how the function
// uses the inputs (if at all), so not a validation error.
Expand All @@ -43,11 +39,9 @@ func UnusedInputRule(_ []*parser.AST, errs *errorhandling.ValidationErrors) Visi
),
)
}

unused = map[string]*parser.NameNode{}
},
EnterActionInput: func(n *parser.ActionInputNode) {
if n.Label == nil || !isAction {
if n.Label == nil {
return
}
unused[n.Label.Value] = n.Label
Expand Down

0 comments on commit 7d63db1

Please sign in to comment.