David Jorm commented on Bug HHH-6672

In general, the bug occurs when a recursive grammar rule includes an exit condition that does not validate it is used inside a recursive call - thus, it can exit at any time, and not only during a recursion, when faced with the exit condition.

Specifically in hql.g, "queryRule" is defined to return (exit) if it sees CLOSE ')' or 'UNION'. These symbols are not a legitimate "exit condition" if there is no recursion currently happening, as mentioned above.

A possible simple solution (albeit not an elegant one), would be to modify the hql.g grammar file to include the following new definition of subQueryRule:

subQueryRule
: selectFrom
(whereClause)?
(groupByClause)?
(orderByClause)?
;

And then modifying the definition of union as follows:

union
: subQueryRule (UNION subQueryRule)*
;

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira