Nim icon indicating copy to clipboard operation
Nim copied to clipboard

echo repr(nil) compiler crash (refc only)

Open avahe-kellenberger opened this issue 2 years ago • 0 comments

What happened?

echo repr(nil) works with arc and orc, but not refc.

refc output:

Error: internal error: genTypeInfoV1(tyNil)
No stack traceback available
To create a stacktrace, rerun compilation with './koch temp r <file>', see https://nim-lang.github.io/Nim/intern.html#debugging-the-compiler for details

orc and arc:

nil

Nim Version

Nim Compiler Version 1.6.6 [Linux: amd64]
Compiled at 2022-05-05
Copyright (c) 2006-2021 by Andreas Rumpf

git hash: 0565a70eab02122ce278b98181c7d1170870865c
active boot switches: -d:release

Current Standard Output Logs

No response

Expected Standard Output Logs

No response

Possible Solution

Have a check for a nil literal, or isNil inside of repr.

Additional Information

No response

avahe-kellenberger avatar Aug 10 '22 05:08 avahe-kellenberger

The issue is that just the nil literal by itself without type information uses a compiler internal type which repr doesn't handle. These work.

echo repr(pointer(nil))
echo repr((ref int)(nil))

metagn avatar Aug 10 '22 14:08 metagn

notnil should be made default, with opt-out cli flag.

juancarlospaco avatar Aug 11 '22 18:08 juancarlospaco