nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.52k stars 1.46k forks source link

Passing anonymous proc params to templates may fail #18648

Open etan-k opened 3 years ago

etan-k commented 3 years ago

Passing an anonymous proc to a template may fail under Nim 1.2.12.

Example

type
  X* = ref object
    bar: proc (p: proc(v: openArray[byte]))

template foo(x: X, p: proc(v: openArray[byte])) =
  x.bar(p)

X().foo(proc(v: openArray[byte]) = discard @v)

Current Output

Error: internal error: expr: param not init v_4602025

Expected Output

Compilation should succeed

Possible Solution

Additional Information

$ nim -v
Nim Compiler Version 1.2.13 [MacOSX: amd64]
Compiled at 2021-08-05
Copyright (c) 2006-2020 by Andreas Rumpf

git hash: 76560576d2dd8ab1876fd4f81029d55467088354
active boot switches: -d:release
metagn commented 2 weeks ago

As mentioned in the issue, works in 1.4 and now