From 617245074815832401ff461ba25430324d011f4b Mon Sep 17 00:00:00 2001 From: Juha Jeronen Date: Sun, 2 May 2021 14:45:47 +0300 Subject: [PATCH] fix syntax analysis in visit_Subscript --- mcpyrate/expander.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mcpyrate/expander.py b/mcpyrate/expander.py index d28f383..e760f45 100644 --- a/mcpyrate/expander.py +++ b/mcpyrate/expander.py @@ -166,8 +166,11 @@ def visit_Subscript(self, subscript): # because things like `(some_expr_macro[tree])[subscript_expression]` are valid. This # is actually exploited by `h`, as in `q[h[target_macro][tree_for_target_macro]]`. candidate = subscript.value - macroname, macroargs = destructure_candidate(candidate, filename=self.filename) + macroname, macroargs = destructure_candidate(candidate, filename=self.filename, + _validate_call_syntax=False) if self.ismacrocall(macroname, macroargs, "expr"): + # Now we know it's a macro invocation, so we can validate the parenthesis syntax to pass arguments. + macroname, macroargs = destructure_candidate(candidate, filename=self.filename) kw = {"args": macroargs} if sys.version_info >= (3, 9, 0): # Python 3.9+: no ast.Index wrapper tree = subscript.slice