Skip to content

proc parameter in return type expression is not gensym'd inside templates #17433

@konsumlamm

Description

@konsumlamm

When using a (proc) parameter in the return type inside a template, it is not gensym'd.

Example

from std/macros import expandMacros

expandMacros:
  template test() =
    proc foo(a: typedesc): a =
      default(a)

Current Output

template main() =
  proc foo(a_385876008: typedesc): a =
    default(a_385876008)

Expected Output

template main() =
  proc foo(a_385876008: typedesc): a_385876008 =
    default(a_385876008)

Possible Solution

This can probably fixed in a similar fashion to #16874.

Additional Information

This also happens when the parameter is used in a nested construct, like a function call.

I found this in #17432.

$ nim -v
Nim Compiler Version 1.5.1 [Linux: amd64]
Compiled at 2021-03-21
Copyright (c) 2006-2021 by Andreas Rumpf

git hash: b70e33f5bbb7b9c146c97d39aabae57504f4ee75
active boot switches: -d:release

EDIT: Use typedesc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions