Nim
Nim copied to clipboard
presumably-invalid `discard R[[R[int]]]()` with `type R[C] = ref object` / `b: C` generates `Error: internal error`
Nim Version
Nim Compiler Version 2.0.14 [Linux: amd64]
Compiled at 2025-04-04
Copyright (c) 2006-2023 by Andreas Rumpf
git hash: bf4de6a394e040d9810cba8c69fb2829ff04dcc6
active boot switches: -d:release
Nim Compiler Version 2.2.3 [Linux: amd64]
Compiled at 2025-04-04
Copyright (c) 2006-2025 by Andreas Rumpf
git hash: 018e63b46c49e2431fd59cdb41ef8f9189eb8ac4
active boot switches: -d:release
Nim Compiler Version 2.3.1 [Linux: amd64]
Compiled at 2025-04-04
Copyright (c) 2006-2025 by Andreas Rumpf
git hash: 10c9ebad9303d9c4be393da913f4e12650783539
active boot switches: -d:release
Description
type R[C] = ref object
b: C
discard R[[R[int]]]()
R[[R[int]]]() is deliberately invalid (-looking?) syntax -- but either:
- rather than being detected as such, it generates different internal errors depending on the memory model used; or
- if it is valid, it ... also generates two internal errors depending on the memory model used.
Current Output
With ORC:
w.nim(3, 20) Error: internal error: '=destroy' operator not found for type R
With refc:
Error: internal error: genTypeInfoV1(tyTypeDesc)
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 compiler internal errors in either ORC or refc
Known Workarounds
No response
Additional Information
No response
Reduced
type R[C] = ref object
b: typedesc[int]
discard R[int]()