diff --git a/ast/parser.go b/ast/parser.go index 88732fe64a..8bf96f0803 100644 --- a/ast/parser.go +++ b/ast/parser.go @@ -802,6 +802,10 @@ func (p *Parser) parseHead(defaultRule bool) (*Head, bool) { case Var: ref = Ref{op} case Ref: + if _, ok := y[0].Value.(Var); !ok { + p.illegal("rule head ref %v invalid", y) + return nil, false + } ref = y } head = RefHead(ref) diff --git a/ast/parser_test.go b/ast/parser_test.go index 4d610f9249..aa4e76d571 100644 --- a/ast/parser_test.go +++ b/ast/parser_test.go @@ -2150,7 +2150,9 @@ func TestRuleRefHeads(t *testing.T) { }) } - // TODO(sr): error cases, non-ground terms anywhere but at the end of the ref + assertParseErrorContains(t, "first ref head term is call", `package p +q(0).r(0) { true }`, + "unexpected { token: rule head ref q(0).r invalid", opts) } func TestRuleElseKeyword(t *testing.T) {