Skip to content

macro: apply recursion bound to imported calls - #382

Open
codexagents wants to merge 1 commit into
flosch:masterfrom
tokenmaxed:sandbox@ns1029703/upstream-macro-bound
Open

macro: apply recursion bound to imported calls#382
codexagents wants to merge 1 commit into
flosch:masterfrom
tokenmaxed:sandbox@ns1029703/upstream-macro-bound

Conversation

@codexagents

Copy link
Copy Markdown

Summary

  • factor the macro callable used at a definition site
  • reuse that callable for imported macros
  • verify both paths stop at the existing 1,000-call recursion bound

Why

Macros registered by {% macro %} increment ExecutionContext.macroDepth, but {% import %} currently installs a different closure that calls the macro body directly. A recursively imported macro therefore bypasses the existing guard and can recurse until the Go runtime terminates the process with a stack overflow.

Using one callable for both registration paths preserves the current limit and error while closing the bypass.

Verification

  • go test ./...
  • go test -race ./...
  • go vet ./...

@sonarqubecloud

Copy link
Copy Markdown

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.

1 participant