Skip to content

Call blocks: macro repr, repeated caller keyword, any call expression (0199) - #544

Merged
rmorozov merged 4 commits into
masterfrom
claude/project-thread-vchonf
Oct 17, 2026
Merged

rmorozov merged 4 commits into
masterfrom
claude/project-thread-vchonf

Conversation

@rmorozov

Copy link
Copy Markdown
Member

Requested by Ruslan · project thread

Before: {{ caller }} and {{ m }} printed nothing, {% call m(caller=c) %} loaded and ran, and {% call ns.m() %} failed to parse ("Expected: '('").

After: a macro prints as <Macro 'm'> and a call block's caller as <Macro anonymous> (also inside lists, dicts and with autoescape), and caller.name is None. {% call m(caller=c) %} is a load error pointing at caller, matching Python's "keyword argument repeated: caller". call takes any call expression (ns.m(), l[0]()), and a non-call (m, m()|e, m() if a else b) is rejected as Jinja2's "expected call" does.

How: ParseCall parses the callee with ExpressionParser::ParseFullExpression and requires a CallExpression; MacroCallStatement holds that node and evaluates its callee at render instead of looking a name up by hash, so the callee is now an ordinary name use for the name resolver (one name_resolver_test row updated). ValueRendererBase renders Callable::Macro values with attributes; other callables still print nothing.

Deliberate divergence: globals, Python methods and other non-macro callables print nothing, since Python's repr of them carries an address.

Parity: three 0199 divergence lines removed; eight new cases under statements.py (attribute/item callee, rejected forms, inner caller= accepted, escaped repr, caller.name). Expectations regenerated under Python 3.12.

Filed 0208 (macros as values: pprint, equality/unique, truncate, call blocks passing caller to callees that do not take it), pinned by statements.macro_pprint and statements.macro_equals_itself.

Roles: verifier (1 round: one blocking finding, a missing <optional> include caught by clang-tidy, already fixed before push; ASan+UBSan, fuzz replay over ~22k mutated call-block inputs and ~190 Python comparisons all clean). Perf gate: all benchmarks within +0.2%. Red pushes: none yet.

Part of the parity merge train with 0201+0202, 0143+0198, 0200+0127.


Generated by Claude Code

… (0199)

A macro prints as <Macro 'm'> and a call block's caller as <Macro anonymous>
(its name is None). {% call m(caller=c) %} is a load error, as Python's
'keyword argument repeated: caller'. The call after 'call' is any call
expression, so ns.m() and l[0]() work; a non-call is rejected.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W4CggH7f8SpGXEXrmTH97u
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W4CggH7f8SpGXEXrmTH97u
…word column

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W4CggH7f8SpGXEXrmTH97u
@rmorozov rmorozov self-assigned this Oct 17, 2026
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W4CggH7f8SpGXEXrmTH97u
@rmorozov
rmorozov marked this pull request as ready for review October 17, 2026 12:47
@rmorozov
rmorozov merged commit bc435d8 into master Oct 17, 2026
41 checks passed
rmorozov added a commit that referenced this pull request Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants