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.56k stars 1.47k forks source link

Proc default arg error, `internal error: expr` #18074

Open al6x opened 3 years ago

al6x commented 3 years ago

Following example would fail with compiler error, playground

Error: internal error: expr: param not init query_13251018

Example

import strformat

proc somefn[T](query: string, _: type[T], message = query) = discard

somefn(fmt"", string)

Current Output

Hint: used config file '/playground/nim/config/nim.cfg' [Conf]
Hint: used config file '/playground/nim/config/config.nims' [Conf]
............
/usercode/in.nim(3, 53) Error: internal error: expr: param not init query_13251018
No stack traceback available
To create a stacktrace, rerun compilation with './koch temp c <file>', see https://nim-lang.github.io/Nim/intern.html#debugging-the-compiler for details
$ nim -v
Nim Compiler Version 1.4.6 [MacOSX: amd64]
Compiled at 2021-05-06
Copyright (c) 2006-2020 by Andreas Rumpf

active boot switches: -d:release
bung87 commented 1 year ago

nkStmtListExpr goes to compiler/ccgcalls.nim genArg else branch

metagn commented 1 week ago

Works since 2.2?