Skip to content

Error: internal error: expr: var not init a_536870917 with non-quasiquoted variable in macro #24641

Open
@tersec

Description

@tersec

Description

import std/macros

macro p(): untyped =
  result = newStmtList()
  var a: int
  result.add quote do:
    discard a

p()

It's true that using, e.g.,

  discard `a`

fixes this, and this isn't meant to be correct-as-such-code. The point here is the Nim compiler internal error.

Nim Version

Nim Compiler Version 2.0.14 [Linux: amd64]
Compiled at 2025-01-23
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: bf4de6a394e040d9810cba8c69fb2829ff04dcc6
active boot switches: -d:release
Nim Compiler Version 2.3.1 [Linux: amd64]
Compiled at 2025-01-23
Copyright (c) 2006-2025 by Andreas Rumpf

git hash: 6d59680217cfbd9314cf62d1d07adc8e6e552d53
active boot switches: -d:release

Current Output

Error: internal error: expr: var not init a_536870917
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

Expected Output

No Nim internal error

Known Workarounds

No response

Additional Information

No response

Metadata

Metadata

Assignees

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