Skip to content

Commit 0e0c095

Browse files
committed
Address review comments
1 parent 5dc7977 commit 0e0c095

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Tools/cases_generator/analyzer.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,11 +343,12 @@ def check_unused(stack: list[StackItem], input_names: dict[str, lexer.Token]) ->
343343
for item in reversed(stack):
344344
if item.name == "unused":
345345
seen_unused = True
346-
elif seen_unused and not item.peek:
346+
elif item.peek:
347+
break
348+
elif seen_unused:
347349
raise analysis_error(f"Cannot have used input '{item.name}' below an unused value on the stack", input_names[item.name])
348350

349351

350-
351352
def analyze_stack(
352353
op: parser.InstDef | parser.Pseudo, replace_op_arg_1: str | None = None
353354
) -> StackEffect:
@@ -685,7 +686,7 @@ def find_stmt_end(node: parser.InstDef, idx: int) -> lexer.Token:
685686
return node.block.tokens[idx+1]
686687

687688
def check_escaping_calls(instr: parser.InstDef, escapes: dict[lexer.Token, EscapingCall]) -> None:
688-
calls = {escapes[t].call for t in escapes}
689+
calls = {e.call for e in escapes.values()}
689690
in_if = 0
690691
tkn_iter = iter(instr.block.tokens)
691692
for tkn in tkn_iter:
@@ -741,7 +742,7 @@ def find_escaping_api_calls(instr: parser.InstDef) -> dict[lexer.Token, Escaping
741742
continue
742743
if tkn.text in ("PyStackRef_CLOSE", "PyStackRef_XCLOSE"):
743744
if len(tokens) <= idx+2:
744-
raise analysis_error("'(' at end", next_tkn)
745+
raise analysis_error("Unexpected end of file", next_tkn)
745746
kills = tokens[idx+2]
746747
if kills.kind != "IDENTIFIER":
747748
raise analysis_error(f"Expected identifier, got '{kills.text}'", kills)

0 commit comments

Comments
 (0)