diff git a/src/nonTerminalDefinitionInlining.ml b/src/nonTerminalDefinitionInlining.ml
index 594c372bb9c53db2bbba2979a9b5d4603350e312..11afd3e8ab317bd1efeaba309d3d6d62fa1de9be 100644
 a/src/nonTerminalDefinitionInlining.ml
+++ b/src/nonTerminalDefinitionInlining.ml
@@ 366,21 +366,17 @@ let inline grammar =
and expand_symbol symbol : rule =
let rule = find grammar symbol in
 expand_rule symbol rule

 (* Expand a rule if necessary. *)
 and expand_rule k r =
try
 (match expanded_state k with
+ (match expanded_state symbol with
 BeingExpanded >
Error.error
 r.positions
 "there is a cycle in the definition of %s." k
+ rule.positions
+ "there is a cycle in the definition of %s." symbol
 Expanded r >
r)
with Not_found >
 mark_as_being_expanded k;
 mark_as_expanded k { r with branches = r.branches >>= expand_branch }
+ mark_as_being_expanded symbol;
+ mark_as_expanded symbol { rule with branches = rule.branches >>= expand_branch }
in
(* If we are in Coq mode, %inline is forbidden. *)