Skip to content

fixes #20811; Nested proc with inner being generic cannot access parameters of outer proc#25837

Open
ringabout wants to merge 2 commits into
develfrom
pr_sdhfj
Open

fixes #20811; Nested proc with inner being generic cannot access parameters of outer proc#25837
ringabout wants to merge 2 commits into
develfrom
pr_sdhfj

Conversation

@ringabout
Copy link
Copy Markdown
Member

fixes #20811

This pull request addresses issues with parameter capture in nested generic procedures and templates, ensuring that outer parameters are correctly visible and accessible within nested scopes. The main changes include a fix in the semantic analysis logic and the addition of targeted regression tests.

Semantic analysis improvements:

  • Updated semGenericStmtSymbol in compiler/semgnrc.nim to ensure that parameters from outer scopes are preserved and accessible in nested generic procedures, fixing visibility issues with captured parameters.

Added regression tests:

Copilot AI review requested due to automatic review settings May 25, 2026 11:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to fix Nim issue #20811 where a nested generic proc cannot access parameters from its enclosing proc, by adjusting the generic pre-pass symbol handling and adding regression tests.

Changes:

  • Updates semGenericStmtSymbol in compiler/semgnrc.nim to try to preserve captured outer parameters during the generic pre-pass.
  • Adds tests/generics/t20811.nim to ensure both generic and non-generic inner procs can access an outer parameter.
  • Extends tests/template/topensym.nim with an #20811 regression block covering template-injected symbol visibility in a nested generic proc.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
compiler/semgnrc.nim Modifies generic pre-pass symbol handling for parameters to address captured-parameter visibility.
tests/generics/t20811.nim New regression test covering nested generic + plain inner proc access to an outer parameter.
tests/template/topensym.nim Adds a regression block to cover template-injected symbol capture/visibility with nested generics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread compiler/semgnrc.nim Outdated
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.

Nested proc with inner being generic cannot access parameters of outer proc

2 participants