diff --git a/internal/analysis/check.go b/internal/analysis/check.go index eeb4717..882df2d 100644 --- a/internal/analysis/check.go +++ b/internal/analysis/check.go @@ -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() diff --git a/internal/analysis/check_test.go b/internal/analysis/check_test.go index c069320..8b9c652 100644 --- a/internal/analysis/check_test.go +++ b/internal/analysis/check_test.go @@ -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()