Skip to content

Nested dirty template in generic proc #23889

@Graveflo

Description

@Graveflo

Description

This might be mentioned elsewhere in another form, but this is a self contained example

this does not work:

template inner(i: int) {.dirty.} =
  let thing = 1

template outer() =
  proc p[T](x: T) =
    inner(5)
    echo thing

outer()
p(0)

but this does:

template inner(i: int) {.dirty.} =
  let thing = 1

template outer() =
  proc p(x: int) =
    inner(5)
    echo thing

outer()
p(0)

Nim Version

Nim Compiler Version 2.1.9 [Linux: amd64]
Compiled at 2024-07-24
Copyright (c) 2006-2024 by Andreas Rumpf

git hash: c1f91c2
active boot switches: -d:releas

Current Output

Error: undeclared identifier: 'thing'

Expected Output

1

Possible Solution

No response

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions