@@ -818,7 +818,9 @@ def initial_calls(node: Any) -> set[str]:
818818 # The seed algorithm retries the base after its last unsuccessful grow.
819819 # Require that retry to reuse a result, not run an operand action again.
820820 for name , rhs in candidates .items ():
821- operand = rhs .alts [- 1 ].items [0 ].item .value
821+ operand_item = rhs .alts [- 1 ].items [0 ].item
822+ assert isinstance (operand_item , NameLeaf )
823+ operand = operand_item .value
822824 rule = self .all_rules [operand ]
823825 if operand not in candidates and not self ._should_memoize (rule ):
824826 reject (name , f"requires operand { operand !r} to use (operator_loop), "
@@ -840,7 +842,9 @@ def _handle_operator_loop(self, node: Rule, rhs: Rhs) -> None:
840842 self .print ("}" )
841843 self .print ("int _mark = p->mark;" )
842844 self ._set_up_token_start_metadata_extraction ()
843- operand = rhs .alts [- 1 ].items [0 ].item .value
845+ operand_item = rhs .alts [- 1 ].items [0 ].item
846+ assert isinstance (operand_item , NameLeaf )
847+ operand = operand_item .value
844848 self .print (f"_res = { operand } _rule(p);" )
845849 self ._check_for_errors ()
846850 self .print ("if (_res == NULL) {" )
@@ -860,6 +864,7 @@ def _handle_operator_loop(self, node: Rule, rhs: Rhs) -> None:
860864 with self .indent ():
861865 for alt in rhs .alts [:- 1 ]:
862866 left , operator , right = alt .items
867+ assert isinstance (operator .item , StringLeaf )
863868 token = self .exact_tokens [ast .literal_eval (operator .item .value )]
864869 self .print (f"case { token } : {{" )
865870 with self .indent ():
0 commit comments