Skip to content

Commit

Permalink
run base diagnostics on oneof
Browse files Browse the repository at this point in the history
  • Loading branch information
ascandone committed Jan 20, 2025
1 parent e6fcf01 commit 9f81e2c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/analysis/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,11 @@ func (res *CheckResult) checkSource(source parser.Source) {
res.checkSource(source)
}

case *parser.SourceOneof:
for _, source := range source.Sources {
res.checkSource(source)
}

case *parser.SourceCapped:
onExit := res.enterCappedSource()

Expand Down
25 changes: 25 additions & 0 deletions internal/analysis/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,31 @@ func TestUnboundVarInSource(t *testing.T) {
)
}

func TestUnboundVarInSourceOneof(t *testing.T) {
t.Parallel()

input := `send [C 1] (
source = oneof { $unbound_var }
destination = @dest
)`

program := parser.Parse(input).Value

diagnostics := analysis.CheckProgram(program).Diagnostics
require.Len(t, diagnostics, 1)

assert.Equal(t,
[]analysis.Diagnostic{
{
Range: parser.RangeOfIndexed(input, "$unbound_var", 0),
Kind: &analysis.UnboundVariable{Name: "unbound_var"},
},
},
diagnostics,
)

}

func TestUnboundVarInDest(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit 9f81e2c

Please sign in to comment.