mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-11 19:59:32 +00:00
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: * Added `tests/generics/t20811.nim` to verify that both generic and plain inner procedures can access parameters from their enclosing procedure. * Extended `tests/template/topensym.nim` with a new block for issue #20811 to test that template-injected parameters are correctly captured and visible in nested generic procedures.
16 lines
190 B
Nim
16 lines
190 B
Nim
discard """
|
|
output: '''42
|
|
42'''
|
|
"""
|
|
|
|
proc outer(j: int) =
|
|
proc genericInner[T](): int =
|
|
j
|
|
|
|
proc plainInner(): int =
|
|
j
|
|
|
|
echo genericInner[int]()
|
|
echo plainInner()
|
|
|
|
outer(42) |