Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Returning address of constant array emits invalid C code #22389

Closed
etan-status opened this issue Aug 5, 2023 · 4 comments · Fixed by #23807
Closed

Returning address of constant array emits invalid C code #22389

etan-status opened this issue Aug 5, 2023 · 4 comments · Fixed by #23807

Comments

@etan-status
Copy link
Contributor

Description

There is invalid codegen when returning an address to a constant array.

func foo(): ptr UncheckedArray[byte] =
  const bar = [0.byte]
  cast[ptr UncheckedArray[byte]](unsafeAddr bar[0])

echo $repr(foo())

Nim Version

Nim Compiler Version 1.6.14 [MacOSX: amd64]
Compiled at 2023-08-05
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: 71ba2e7f3c5815d956b1ae0341b0743242b8fec6
active boot switches: -d:release

Current Output

CC: test.nim
/Users/etan/Documents/Repos/nimbus-eth2/test.nim:2:75: error: cannot take the address of an rvalue of type 'NU8' (aka 'unsigned char')
        nimln_(2, "/Users/etan/Documents/Repos/nimbus-eth2/test.nim");  result = (&((NU8) 0));  popFrame();     return result;}
                                                                                  ^ ~~~~~~~
1 error generated.
Error: execution of an external compiler program 'clang -c  -w -ferror-limit=3 -pthread -I/Users/etan/Documents/Repos/nimbus-eth2/vendor/nim-libbacktrace -I/Users/etan/Documents/Repos/nimbus-eth2/vendor/nim-libbacktrace/install/usr/include -fvisibility=hidden -march=native -fno-omit-frame-pointer -g -O3   -I/Users/etan/Documents/Repos/nimbus-eth2/vendor/nimbus-build-system/vendor/Nim/lib -I/Users/etan/Documents/Repos/nimbus-eth2 -o /Users/etan/Documents/Repos/nimbus-eth2/nimcache/debug/test/@mtest.nim.c.o /Users/etan/Documents/Repos/nimbus-eth2/nimcache/debug/test/@mtest.nim.c' failed with exit code: 1

Expected Output

A valid address

Possible Solution

No response

Additional Information

No response

@etan-status
Copy link
Contributor Author

Using a cstring works:

proc foo(): ptr UncheckedArray[byte] =
  const bar: cstring = ""
  cast[ptr UncheckedArray[byte]](bar)

echo $repr(foo()[0])

@ringabout
Copy link
Member

related #19840

@juancarlospaco
Copy link
Collaborator

!nim c --gc:arc

func foo(): ptr UncheckedArray[byte] =
  const bar = [0.byte]
  cast[ptr UncheckedArray[byte]](unsafeAddr bar[0])

echo $repr(foo())

@github-actions
Copy link
Contributor

github-actions bot commented Aug 6, 2023

@juancarlospaco (collaborator)

devel 👎 FAIL

Output

Error: Command failed: nim c --gc:arc -d:nimArcDebug -d:nimArcIds  --run  -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --styleCheck:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
command line(1, 2) Warning: `gc:option` is deprecated; use `mm:option` instead [Deprecated]
/home/runner/work/Nim/Nim/@mtemp.nim.c: In function ‘foo__temp_u1’:
/home/runner/work/Nim/Nim/@mtemp.nim.c:86:19: error: lvalue required as unary ‘&’ operand
   86 |         result = (&((NU8)0));
      |                   ^
Error: execution of an external compiler program 'gcc -c  -w -fmax-errors=3 -pthread   -I'/home/runner/.choosenim/toolchains/nim-#devel/lib' -I/home/runner/work/Nim/Nim -o /home/runner/work/Nim/Nim/@mtemp.nim.c.o /home/runner/work/Nim/Nim/@mtemp.nim.c' failed with exit code: 1

Stats

  • Started 2023-08-06T21:35:06
  • Finished 2023-08-06T21:35:06
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
#define nimfr_(proc, file) \
  TFrame FR_; \
  FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
  #define nimfrs_(proc, file, slots, length) \
    struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename;NI len;VarSlot s[slots];} FR_; \
    FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
  #define nimln_(n) \
    FR_.line = n;
  #define nimlf_(n, file) \
    FR_.line = n; FR_.filename = file;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
struct NimStrPayload {
	NI cap;
	NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
	NI len;
	NimStrPayload* p;
};
typedef NimStringV2 tyArray__nHXaesL0DJZHyVS07ARPRA[1];
typedef NU8 tyUncheckedArray__nMUrxcwM7yrVbfFpM3W4Sw[1];
N_LIB_PRIVATE N_NIMCALL(NimStringV2, repr__temp_u36)(NU8* x_p0);
N_LIB_PRIVATE N_NIMCALL(NU8*, foo__temp_u1)(void);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4123)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringV2* args_p0, NI args_p0Len_0);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
extern NIM_THREADVAR TFrame* framePtr__system_u3578;
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u3933;
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
	{
		if (!(framePtr__system_u3578 == ((TFrame*) NIM_NIL))) goto LA3_;
		(*s_p0).calldepth = ((NI16)0);
	}
	goto LA1_;
LA3_: ;
	{
		(*s_p0).calldepth = (NI16)((*framePtr__system_u3578).calldepth + ((NI16)1));
	}
LA1_: ;
	(*s_p0).prev = framePtr__system_u3578;
	framePtr__system_u3578 = s_p0;
	{
		if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
		callDepthLimitReached__system_u4123();
	}
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
	framePtr__system_u3578 = (*framePtr__system_u3578).prev;
}
N_LIB_PRIVATE N_NIMCALL(NU8*, foo__temp_u1)(void) {
	NU8* result;
	nimfr_("foo", "/home/runner/work/Nim/Nim/temp.nim");
	result = (NU8*)0;
	result = (&((NU8)0));
	popFrame();
	return result;
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
	NIM_BOOL* result;
	result = (NIM_BOOL*)0;
	result = (&nimInErrorMode__system_u3933);
	return result;
}
N_LIB_PRIVATE void PreMainInner(void) {
}
N_LIB_PRIVATE int cmdCount;
N_LIB_PRIVATE char** cmdLine;
N_LIB_PRIVATE char** gEnv;
N_LIB_PRIVATE void PreMain(void) {
#if 0
	void (*volatile inner)(void);
	inner = PreMainInner;
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystemdotnim_Init000();
	(*inner)();
#else
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystemdotnim_Init000();
	PreMainInner();
#endif
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
	NimMainModule();
}
N_CDECL(void, NimMain)(void) {
#if 0
	void (*volatile inner)(void);
	PreMain();
	inner = NimMainInner;
	(*inner)();
#else
	PreMain();
	NimMainInner();
#endif
}
int main(int argc, char** args, char** env) {
	cmdLine = args;
	cmdCount = argc;
	gEnv = env;
	NimMain();
	return nim_program_result;
}
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) {
{
	NimStringV2 colontmpD_;
	tyArray__nHXaesL0DJZHyVS07ARPRA T2_;
	NU8* T3_;
NIM_BOOL* nimErr_;
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
	colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
	T3_ = (NU8*)0;
	T3_ = foo__temp_u1();
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	colontmpD_ = repr__temp_u36(T3_);
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	T2_[0] = colontmpD_;
	echoBinSafe(T2_, 1);
	{
		LA1_:;
	}
	{
		if (colontmpD_.p && !(colontmpD_.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared(colontmpD_.p);
}
	}
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	BeforeRet_: ;
	nimTestErrorFlag();
	popFrame();
}
}

AST

nnkStmtList.newTree(
  nnkFuncDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      nnkPtrTy.newTree(
        nnkBracketExpr.newTree(
          newIdentNode("UncheckedArray"),
          newIdentNode("byte")
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkConstSection.newTree(
        nnkConstDef.newTree(
          newIdentNode("bar"),
          newEmptyNode(),
          nnkBracket.newTree(
            nnkDotExpr.newTree(
              newLit(0),
              newIdentNode("byte")
            )
          )
        )
      ),
      nnkCast.newTree(
        nnkPtrTy.newTree(
          nnkBracketExpr.newTree(
            newIdentNode("UncheckedArray"),
            newIdentNode("byte")
          )
        ),
        nnkCommand.newTree(
          newIdentNode("unsafeAddr"),
          nnkBracketExpr.newTree(
            newIdentNode("bar"),
            newLit(0)
          )
        )
      )
    )
  ),
  nnkCommand.newTree(
    newIdentNode("echo"),
    nnkPrefix.newTree(
      newIdentNode("$"),
      nnkCall.newTree(
        newIdentNode("repr"),
        nnkCall.newTree(
          newIdentNode("foo")
        )
      )
    )
  )
)
stable 👎 FAIL

Output

Error: Command failed: nim c --gc:arc -d:nimArcDebug -d:nimArcIds  --run  -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --styleCheck:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
command line(1, 2) Warning: `gc:option` is deprecated; use `mm:option` instead [Deprecated]
/home/runner/work/Nim/Nim/@mtemp.nim.c: In function ‘foo__temp_u1’:
/home/runner/work/Nim/Nim/@mtemp.nim.c:86:19: error: lvalue required as unary ‘&’ operand
   86 |         result = (&((NU8)0));
      |                   ^
Error: execution of an external compiler program 'gcc -c  -w -fmax-errors=3 -pthread   -I/home/runner/.choosenim/toolchains/nim-2.0.0/lib -I/home/runner/work/Nim/Nim -o /home/runner/work/Nim/Nim/@mtemp.nim.c.o /home/runner/work/Nim/Nim/@mtemp.nim.c' failed with exit code: 1

Stats

  • Started 2023-08-06T21:35:07
  • Finished 2023-08-06T21:35:07
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
#define nimfr_(proc, file) \
  TFrame FR_; \
  FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
  #define nimfrs_(proc, file, slots, length) \
    struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename;NI len;VarSlot s[slots];} FR_; \
    FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
  #define nimln_(n) \
    FR_.line = n;
  #define nimlf_(n, file) \
    FR_.line = n; FR_.filename = file;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
struct NimStrPayload {
	NI cap;
	NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
	NI len;
	NimStrPayload* p;
};
typedef NimStringV2 tyArray__nHXaesL0DJZHyVS07ARPRA[1];
typedef NU8 tyUncheckedArray__nMUrxcwM7yrVbfFpM3W4Sw[1];
N_LIB_PRIVATE N_NIMCALL(NimStringV2, repr__temp_u36)(NU8* x_p0);
N_LIB_PRIVATE N_NIMCALL(NU8*, foo__temp_u1)(void);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4159)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringV2* args_p0, NI args_p0Len_0);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
extern NIM_THREADVAR TFrame* framePtr__system_u3605;
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u3967;
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
	{
		if (!(framePtr__system_u3605 == ((TFrame*) NIM_NIL))) goto LA3_;
		(*s_p0).calldepth = ((NI16)0);
	}
	goto LA1_;
LA3_: ;
	{
		(*s_p0).calldepth = (NI16)((*framePtr__system_u3605).calldepth + ((NI16)1));
	}
LA1_: ;
	(*s_p0).prev = framePtr__system_u3605;
	framePtr__system_u3605 = s_p0;
	{
		if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
		callDepthLimitReached__system_u4159();
	}
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
	framePtr__system_u3605 = (*framePtr__system_u3605).prev;
}
N_LIB_PRIVATE N_NIMCALL(NU8*, foo__temp_u1)(void) {
	NU8* result;
	nimfr_("foo", "/home/runner/work/Nim/Nim/temp.nim");
	result = (NU8*)0;
	result = (&((NU8)0));
	popFrame();
	return result;
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
	NIM_BOOL* result;
	result = (NIM_BOOL*)0;
	result = (&nimInErrorMode__system_u3967);
	return result;
}
N_LIB_PRIVATE void PreMainInner(void) {
}
N_LIB_PRIVATE int cmdCount;
N_LIB_PRIVATE char** cmdLine;
N_LIB_PRIVATE char** gEnv;
N_LIB_PRIVATE void PreMain(void) {
#if 0
	void (*volatile inner)(void);
	inner = PreMainInner;
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000();
	(*inner)();
#else
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000();
	PreMainInner();
#endif
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
	NimMainModule();
}
N_CDECL(void, NimMain)(void) {
#if 0
	void (*volatile inner)(void);
	PreMain();
	inner = NimMainInner;
	(*inner)();
#else
	PreMain();
	NimMainInner();
#endif
}
int main(int argc, char** args, char** env) {
	cmdLine = args;
	cmdCount = argc;
	gEnv = env;
	NimMain();
	return nim_program_result;
}
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) {
{
	NimStringV2 colontmpD_;
	tyArray__nHXaesL0DJZHyVS07ARPRA T2_;
	NU8* T3_;
NIM_BOOL* nimErr_;
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
	colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
	T3_ = (NU8*)0;
	T3_ = foo__temp_u1();
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	colontmpD_ = repr__temp_u36(T3_);
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	T2_[0] = colontmpD_;
	echoBinSafe(T2_, 1);
	{
		LA1_:;
	}
	{
		if (colontmpD_.p && !(colontmpD_.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared(colontmpD_.p);
}
	}
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	BeforeRet_: ;
	nimTestErrorFlag();
	popFrame();
}
}

AST

nnkStmtList.newTree(
  nnkFuncDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      nnkPtrTy.newTree(
        nnkBracketExpr.newTree(
          newIdentNode("UncheckedArray"),
          newIdentNode("byte")
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkConstSection.newTree(
        nnkConstDef.newTree(
          newIdentNode("bar"),
          newEmptyNode(),
          nnkBracket.newTree(
            nnkDotExpr.newTree(
              newLit(0),
              newIdentNode("byte")
            )
          )
        )
      ),
      nnkCast.newTree(
        nnkPtrTy.newTree(
          nnkBracketExpr.newTree(
            newIdentNode("UncheckedArray"),
            newIdentNode("byte")
          )
        ),
        nnkCommand.newTree(
          newIdentNode("unsafeAddr"),
          nnkBracketExpr.newTree(
            newIdentNode("bar"),
            newLit(0)
          )
        )
      )
    )
  ),
  nnkCommand.newTree(
    newIdentNode("echo"),
    nnkPrefix.newTree(
      newIdentNode("$"),
      nnkCall.newTree(
        newIdentNode("repr"),
        nnkCall.newTree(
          newIdentNode("foo")
        )
      )
    )
  )
)
2.0.0 👎 FAIL

Output

Error: Command failed: nim c --gc:arc -d:nimArcDebug -d:nimArcIds  --run  -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --styleCheck:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
command line(1, 2) Warning: `gc:option` is deprecated; use `mm:option` instead [Deprecated]
/home/runner/work/Nim/Nim/@mtemp.nim.c: In function ‘foo__temp_u1’:
/home/runner/work/Nim/Nim/@mtemp.nim.c:86:19: error: lvalue required as unary ‘&’ operand
   86 |         result = (&((NU8)0));
      |                   ^
Error: execution of an external compiler program 'gcc -c  -w -fmax-errors=3 -pthread   -I/home/runner/.choosenim/toolchains/nim-2.0.0/lib -I/home/runner/work/Nim/Nim -o /home/runner/work/Nim/Nim/@mtemp.nim.c.o /home/runner/work/Nim/Nim/@mtemp.nim.c' failed with exit code: 1

Stats

  • Started 2023-08-06T21:35:08
  • Finished 2023-08-06T21:35:08
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
#define nimfr_(proc, file) \
  TFrame FR_; \
  FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
  #define nimfrs_(proc, file, slots, length) \
    struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename;NI len;VarSlot s[slots];} FR_; \
    FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
  #define nimln_(n) \
    FR_.line = n;
  #define nimlf_(n, file) \
    FR_.line = n; FR_.filename = file;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
struct NimStrPayload {
	NI cap;
	NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
	NI len;
	NimStrPayload* p;
};
typedef NimStringV2 tyArray__nHXaesL0DJZHyVS07ARPRA[1];
typedef NU8 tyUncheckedArray__nMUrxcwM7yrVbfFpM3W4Sw[1];
N_LIB_PRIVATE N_NIMCALL(NimStringV2, repr__temp_u36)(NU8* x_p0);
N_LIB_PRIVATE N_NIMCALL(NU8*, foo__temp_u1)(void);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4159)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringV2* args_p0, NI args_p0Len_0);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
extern NIM_THREADVAR TFrame* framePtr__system_u3605;
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u3967;
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
	{
		if (!(framePtr__system_u3605 == ((TFrame*) NIM_NIL))) goto LA3_;
		(*s_p0).calldepth = ((NI16)0);
	}
	goto LA1_;
LA3_: ;
	{
		(*s_p0).calldepth = (NI16)((*framePtr__system_u3605).calldepth + ((NI16)1));
	}
LA1_: ;
	(*s_p0).prev = framePtr__system_u3605;
	framePtr__system_u3605 = s_p0;
	{
		if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
		callDepthLimitReached__system_u4159();
	}
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
	framePtr__system_u3605 = (*framePtr__system_u3605).prev;
}
N_LIB_PRIVATE N_NIMCALL(NU8*, foo__temp_u1)(void) {
	NU8* result;
	nimfr_("foo", "/home/runner/work/Nim/Nim/temp.nim");
	result = (NU8*)0;
	result = (&((NU8)0));
	popFrame();
	return result;
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
	NIM_BOOL* result;
	result = (NIM_BOOL*)0;
	result = (&nimInErrorMode__system_u3967);
	return result;
}
N_LIB_PRIVATE void PreMainInner(void) {
}
N_LIB_PRIVATE int cmdCount;
N_LIB_PRIVATE char** cmdLine;
N_LIB_PRIVATE char** gEnv;
N_LIB_PRIVATE void PreMain(void) {
#if 0
	void (*volatile inner)(void);
	inner = PreMainInner;
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000();
	(*inner)();
#else
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000();
	PreMainInner();
#endif
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
	NimMainModule();
}
N_CDECL(void, NimMain)(void) {
#if 0
	void (*volatile inner)(void);
	PreMain();
	inner = NimMainInner;
	(*inner)();
#else
	PreMain();
	NimMainInner();
#endif
}
int main(int argc, char** args, char** env) {
	cmdLine = args;
	cmdCount = argc;
	gEnv = env;
	NimMain();
	return nim_program_result;
}
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) {
{
	NimStringV2 colontmpD_;
	tyArray__nHXaesL0DJZHyVS07ARPRA T2_;
	NU8* T3_;
NIM_BOOL* nimErr_;
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
	colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
	T3_ = (NU8*)0;
	T3_ = foo__temp_u1();
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	colontmpD_ = repr__temp_u36(T3_);
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	T2_[0] = colontmpD_;
	echoBinSafe(T2_, 1);
	{
		LA1_:;
	}
	{
		if (colontmpD_.p && !(colontmpD_.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared(colontmpD_.p);
}
	}
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	BeforeRet_: ;
	nimTestErrorFlag();
	popFrame();
}
}

AST

nnkStmtList.newTree(
  nnkFuncDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      nnkPtrTy.newTree(
        nnkBracketExpr.newTree(
          newIdentNode("UncheckedArray"),
          newIdentNode("byte")
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkConstSection.newTree(
        nnkConstDef.newTree(
          newIdentNode("bar"),
          newEmptyNode(),
          nnkBracket.newTree(
            nnkDotExpr.newTree(
              newLit(0),
              newIdentNode("byte")
            )
          )
        )
      ),
      nnkCast.newTree(
        nnkPtrTy.newTree(
          nnkBracketExpr.newTree(
            newIdentNode("UncheckedArray"),
            newIdentNode("byte")
          )
        ),
        nnkCommand.newTree(
          newIdentNode("unsafeAddr"),
          nnkBracketExpr.newTree(
            newIdentNode("bar"),
            newLit(0)
          )
        )
      )
    )
  ),
  nnkCommand.newTree(
    newIdentNode("echo"),
    nnkPrefix.newTree(
      newIdentNode("$"),
      nnkCall.newTree(
        newIdentNode("repr"),
        nnkCall.newTree(
          newIdentNode("foo")
        )
      )
    )
  )
)
1.6.0 👎 FAIL

Output

Error: Command failed: nim c --gc:arc -d:nimArcDebug -d:nimArcIds  --run  -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --styleCheck:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/temp.nim(4, 11) template/generic instantiation of `repr` from here
/home/runner/.choosenim/toolchains/nim-1.6.0/lib/system/repr_v2.nim(140, 20) Error: type mismatch: got <UncheckedArray[byte]>
but expected one of:
proc repr(p: pointer): string
  first type mismatch at position: 1
  required type for p: pointer
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr(p: proc): string
  first type mismatch at position: 1
  required type for p: proc
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr(x: NimNode): string
  first type mismatch at position: 1
  required type for x: NimNode
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr(x: bool): string
  first type mismatch at position: 1
  required type for x: bool
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr(x: char): string
  first type mismatch at position: 1
  required type for x: char
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr(x: float): string
  first type mismatch at position: 1
  required type for x: float
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr(x: int): string
  first type mismatch at position: 1
  required type for x: int
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr(x: int64): string
  first type mismatch at position: 1
  required type for x: int64
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr(x: string | cstring): string
  first type mismatch at position: 1
  required type for x: string or cstring
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr(x: uint64): string
  first type mismatch at position: 1
  required type for x: uint64
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr[Enum: enum](x: Enum): string
  first type mismatch at position: 1
  required type for x: Enum: enum
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr[T, IDX](x: array[IDX, T]): string
  first type mismatch at position: 1
  required type for x: array[IDX, T]
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr[T, U](x: HSlice[T, U]): string
  first type mismatch at position: 1
  required type for x: HSlice[repr.T, repr.U]
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr[T: tuple | object](x: T): string
  first type mismatch at position: 1
  required type for x: T: tuple or object
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr[T](x: openArray[T]): string
  first type mismatch at position: 1
  required type for x: openArray[T]
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr[T](x: ref T | ptr T): string
  first type mismatch at position: 1
  required type for x: ref T or ptr T
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr[T](x: seq[T]): string
  first type mismatch at position: 1
  required type for x: seq[T]
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr[T](x: set[T]): string
  first type mismatch at position: 1
  required type for x: set[T]
  but expression 'x[]' is of type: UncheckedArray[byte]
template repr(t: typedesc): string
  first type mismatch at position: 1
  required type for t: typedesc
  but expression 'x[]' is of type: UncheckedArray[byte]
template repr(x: distinct): string
  first type mismatch at position: 1
  required type for x: distinct
  but expression 'x[]' is of type: UncheckedArray[byte]

expression: repr(x[])

Stats

  • Started 2023-08-06T21:35:11
  • Finished 2023-08-06T21:35:11
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
#define nimfr_(proc, file) \
  TFrame FR_; \
  FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
  #define nimfrs_(proc, file, slots, length) \
    struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename;NI len;VarSlot s[slots];} FR_; \
    FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
  #define nimln_(n) \
    FR_.line = n;
  #define nimlf_(n, file) \
    FR_.line = n; FR_.filename = file;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
struct NimStrPayload {
	NI cap;
	NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
	NI len;
	NimStrPayload* p;
};
typedef NimStringV2 tyArray__nHXaesL0DJZHyVS07ARPRA[1];
typedef NU8 tyUncheckedArray__nMUrxcwM7yrVbfFpM3W4Sw[1];
N_LIB_PRIVATE N_NIMCALL(NimStringV2, repr__temp_u36)(NU8* x_p0);
N_LIB_PRIVATE N_NIMCALL(NU8*, foo__temp_u1)(void);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4159)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringV2* args_p0, NI args_p0Len_0);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
extern NIM_THREADVAR TFrame* framePtr__system_u3605;
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u3967;
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
	{
		if (!(framePtr__system_u3605 == ((TFrame*) NIM_NIL))) goto LA3_;
		(*s_p0).calldepth = ((NI16)0);
	}
	goto LA1_;
LA3_: ;
	{
		(*s_p0).calldepth = (NI16)((*framePtr__system_u3605).calldepth + ((NI16)1));
	}
LA1_: ;
	(*s_p0).prev = framePtr__system_u3605;
	framePtr__system_u3605 = s_p0;
	{
		if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
		callDepthLimitReached__system_u4159();
	}
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
	framePtr__system_u3605 = (*framePtr__system_u3605).prev;
}
N_LIB_PRIVATE N_NIMCALL(NU8*, foo__temp_u1)(void) {
	NU8* result;
	nimfr_("foo", "/home/runner/work/Nim/Nim/temp.nim");
	result = (NU8*)0;
	result = (&((NU8)0));
	popFrame();
	return result;
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
	NIM_BOOL* result;
	result = (NIM_BOOL*)0;
	result = (&nimInErrorMode__system_u3967);
	return result;
}
N_LIB_PRIVATE void PreMainInner(void) {
}
N_LIB_PRIVATE int cmdCount;
N_LIB_PRIVATE char** cmdLine;
N_LIB_PRIVATE char** gEnv;
N_LIB_PRIVATE void PreMain(void) {
#if 0
	void (*volatile inner)(void);
	inner = PreMainInner;
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000();
	(*inner)();
#else
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000();
	PreMainInner();
#endif
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
	NimMainModule();
}
N_CDECL(void, NimMain)(void) {
#if 0
	void (*volatile inner)(void);
	PreMain();
	inner = NimMainInner;
	(*inner)();
#else
	PreMain();
	NimMainInner();
#endif
}
int main(int argc, char** args, char** env) {
	cmdLine = args;
	cmdCount = argc;
	gEnv = env;
	NimMain();
	return nim_program_result;
}
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) {
{
	NimStringV2 colontmpD_;
	tyArray__nHXaesL0DJZHyVS07ARPRA T2_;
	NU8* T3_;
NIM_BOOL* nimErr_;
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
	colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
	T3_ = (NU8*)0;
	T3_ = foo__temp_u1();
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	colontmpD_ = repr__temp_u36(T3_);
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	T2_[0] = colontmpD_;
	echoBinSafe(T2_, 1);
	{
		LA1_:;
	}
	{
		if (colontmpD_.p && !(colontmpD_.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared(colontmpD_.p);
}
	}
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	BeforeRet_: ;
	nimTestErrorFlag();
	popFrame();
}
}

AST

nnkStmtList.newTree(
  nnkFuncDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      nnkPtrTy.newTree(
        nnkBracketExpr.newTree(
          newIdentNode("UncheckedArray"),
          newIdentNode("byte")
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkConstSection.newTree(
        nnkConstDef.newTree(
          newIdentNode("bar"),
          newEmptyNode(),
          nnkBracket.newTree(
            nnkDotExpr.newTree(
              newLit(0),
              newIdentNode("byte")
            )
          )
        )
      ),
      nnkCast.newTree(
        nnkPtrTy.newTree(
          nnkBracketExpr.newTree(
            newIdentNode("UncheckedArray"),
            newIdentNode("byte")
          )
        ),
        nnkCommand.newTree(
          newIdentNode("unsafeAddr"),
          nnkBracketExpr.newTree(
            newIdentNode("bar"),
            newLit(0)
          )
        )
      )
    )
  ),
  nnkCommand.newTree(
    newIdentNode("echo"),
    nnkPrefix.newTree(
      newIdentNode("$"),
      nnkCall.newTree(
        newIdentNode("repr"),
        nnkCall.newTree(
          newIdentNode("foo")
        )
      )
    )
  )
)
1.4.0 👎 FAIL

Output

Error: Command failed: nim c --gc:arc -d:nimArcDebug -d:nimArcIds  --run  -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --styleCheck:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/temp.nim(4, 11) template/generic instantiation of `repr` from here
/home/runner/.choosenim/toolchains/nim-1.4.0/lib/system/repr_v2.nim(134, 20) Error: type mismatch: got <UncheckedArray[byte]>
but expected one of: 
proc repr(p: pointer): string
  first type mismatch at position: 1
  required type for p: pointer
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr(p: proc): string
  first type mismatch at position: 1
  required type for p: proc
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr(x: NimNode): string
  first type mismatch at position: 1
  required type for x: NimNode
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr(x: bool): string
  first type mismatch at position: 1
  required type for x: bool
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr(x: char): string
  first type mismatch at position: 1
  required type for x: char
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr(x: float): string
  first type mismatch at position: 1
  required type for x: float
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr(x: int): string
  first type mismatch at position: 1
  required type for x: int
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr(x: int64): string
  first type mismatch at position: 1
  required type for x: int64
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr(x: string | cstring): string
  first type mismatch at position: 1
  required type for x: string or cstring
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr(x: uint64): string
  first type mismatch at position: 1
  required type for x: uint64
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr[Enum: enum](x: Enum): string
  first type mismatch at position: 1
  required type for x: Enum: enum
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr[T, IDX](x: array[IDX, T]): string
  first type mismatch at position: 1
  required type for x: array[IDX, T]
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr[T, U](x: HSlice[T, U]): string
  first type mismatch at position: 1
  required type for x: HSlice[repr.T, repr.U]
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr[T: tuple | object](x: T): string
  first type mismatch at position: 1
  required type for x: T: tuple or object
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr[T](x: openArray[T]): string
  first type mismatch at position: 1
  required type for x: openArray[T]
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr[T](x: ref T | ptr T): string
  first type mismatch at position: 1
  required type for x: ref T or ptr T
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr[T](x: seq[T]): string
  first type mismatch at position: 1
  required type for x: seq[T]
  but expression 'x[]' is of type: UncheckedArray[byte]
proc repr[T](x: set[T]): string
  first type mismatch at position: 1
  required type for x: set[T]
  but expression 'x[]' is of type: UncheckedArray[byte]
template repr(t: typedesc): string
  first type mismatch at position: 1
  required type for t: typedesc
  but expression 'x[]' is of type: UncheckedArray[byte]
template repr(x: distinct): string
  first type mismatch at position: 1
  required type for x: distinct
  but expression 'x[]' is of type: UncheckedArray[byte]

expression: repr(x[])

Stats

  • Started 2023-08-06T21:35:13
  • Finished 2023-08-06T21:35:14
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
#define nimfr_(proc, file) \
  TFrame FR_; \
  FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
  #define nimfrs_(proc, file, slots, length) \
    struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename;NI len;VarSlot s[slots];} FR_; \
    FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
  #define nimln_(n) \
    FR_.line = n;
  #define nimlf_(n, file) \
    FR_.line = n; FR_.filename = file;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
struct NimStrPayload {
	NI cap;
	NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
	NI len;
	NimStrPayload* p;
};
typedef NimStringV2 tyArray__nHXaesL0DJZHyVS07ARPRA[1];
typedef NU8 tyUncheckedArray__nMUrxcwM7yrVbfFpM3W4Sw[1];
N_LIB_PRIVATE N_NIMCALL(NimStringV2, repr__temp_u36)(NU8* x_p0);
N_LIB_PRIVATE N_NIMCALL(NU8*, foo__temp_u1)(void);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4159)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringV2* args_p0, NI args_p0Len_0);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
extern NIM_THREADVAR TFrame* framePtr__system_u3605;
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u3967;
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
	{
		if (!(framePtr__system_u3605 == ((TFrame*) NIM_NIL))) goto LA3_;
		(*s_p0).calldepth = ((NI16)0);
	}
	goto LA1_;
LA3_: ;
	{
		(*s_p0).calldepth = (NI16)((*framePtr__system_u3605).calldepth + ((NI16)1));
	}
LA1_: ;
	(*s_p0).prev = framePtr__system_u3605;
	framePtr__system_u3605 = s_p0;
	{
		if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
		callDepthLimitReached__system_u4159();
	}
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
	framePtr__system_u3605 = (*framePtr__system_u3605).prev;
}
N_LIB_PRIVATE N_NIMCALL(NU8*, foo__temp_u1)(void) {
	NU8* result;
	nimfr_("foo", "/home/runner/work/Nim/Nim/temp.nim");
	result = (NU8*)0;
	result = (&((NU8)0));
	popFrame();
	return result;
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
	NIM_BOOL* result;
	result = (NIM_BOOL*)0;
	result = (&nimInErrorMode__system_u3967);
	return result;
}
N_LIB_PRIVATE void PreMainInner(void) {
}
N_LIB_PRIVATE int cmdCount;
N_LIB_PRIVATE char** cmdLine;
N_LIB_PRIVATE char** gEnv;
N_LIB_PRIVATE void PreMain(void) {
#if 0
	void (*volatile inner)(void);
	inner = PreMainInner;
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000();
	(*inner)();
#else
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000();
	PreMainInner();
#endif
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
	NimMainModule();
}
N_CDECL(void, NimMain)(void) {
#if 0
	void (*volatile inner)(void);
	PreMain();
	inner = NimMainInner;
	(*inner)();
#else
	PreMain();
	NimMainInner();
#endif
}
int main(int argc, char** args, char** env) {
	cmdLine = args;
	cmdCount = argc;
	gEnv = env;
	NimMain();
	return nim_program_result;
}
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) {
{
	NimStringV2 colontmpD_;
	tyArray__nHXaesL0DJZHyVS07ARPRA T2_;
	NU8* T3_;
NIM_BOOL* nimErr_;
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
	colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
	T3_ = (NU8*)0;
	T3_ = foo__temp_u1();
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	colontmpD_ = repr__temp_u36(T3_);
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	T2_[0] = colontmpD_;
	echoBinSafe(T2_, 1);
	{
		LA1_:;
	}
	{
		if (colontmpD_.p && !(colontmpD_.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared(colontmpD_.p);
}
	}
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	BeforeRet_: ;
	nimTestErrorFlag();
	popFrame();
}
}

AST

nnkStmtList.newTree(
  nnkFuncDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      nnkPtrTy.newTree(
        nnkBracketExpr.newTree(
          newIdentNode("UncheckedArray"),
          newIdentNode("byte")
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkConstSection.newTree(
        nnkConstDef.newTree(
          newIdentNode("bar"),
          newEmptyNode(),
          nnkBracket.newTree(
            nnkDotExpr.newTree(
              newLit(0),
              newIdentNode("byte")
            )
          )
        )
      ),
      nnkCast.newTree(
        nnkPtrTy.newTree(
          nnkBracketExpr.newTree(
            newIdentNode("UncheckedArray"),
            newIdentNode("byte")
          )
        ),
        nnkCommand.newTree(
          newIdentNode("unsafeAddr"),
          nnkBracketExpr.newTree(
            newIdentNode("bar"),
            newLit(0)
          )
        )
      )
    )
  ),
  nnkCommand.newTree(
    newIdentNode("echo"),
    nnkPrefix.newTree(
      newIdentNode("$"),
      nnkCall.newTree(
        newIdentNode("repr"),
        nnkCall.newTree(
          newIdentNode("foo")
        )
      )
    )
  )
)
1.2.0 👎 FAIL

Output

Error: Command failed: nim c --gc:arc -d:nimArcDebug -d:nimArcIds  --run  -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --styleCheck:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/temp.nim(3, 48) Error: expression has no address

Stats

  • Started 2023-08-06T21:35:29
  • Finished 2023-08-06T21:35:29
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
#define nimfr_(proc, file) \
  TFrame FR_; \
  FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
  #define nimfrs_(proc, file, slots, length) \
    struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename;NI len;VarSlot s[slots];} FR_; \
    FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
  #define nimln_(n) \
    FR_.line = n;
  #define nimlf_(n, file) \
    FR_.line = n; FR_.filename = file;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
struct NimStrPayload {
	NI cap;
	NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
	NI len;
	NimStrPayload* p;
};
typedef NimStringV2 tyArray__nHXaesL0DJZHyVS07ARPRA[1];
typedef NU8 tyUncheckedArray__nMUrxcwM7yrVbfFpM3W4Sw[1];
N_LIB_PRIVATE N_NIMCALL(NimStringV2, repr__temp_u36)(NU8* x_p0);
N_LIB_PRIVATE N_NIMCALL(NU8*, foo__temp_u1)(void);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4159)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringV2* args_p0, NI args_p0Len_0);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
extern NIM_THREADVAR TFrame* framePtr__system_u3605;
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u3967;
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
	{
		if (!(framePtr__system_u3605 == ((TFrame*) NIM_NIL))) goto LA3_;
		(*s_p0).calldepth = ((NI16)0);
	}
	goto LA1_;
LA3_: ;
	{
		(*s_p0).calldepth = (NI16)((*framePtr__system_u3605).calldepth + ((NI16)1));
	}
LA1_: ;
	(*s_p0).prev = framePtr__system_u3605;
	framePtr__system_u3605 = s_p0;
	{
		if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
		callDepthLimitReached__system_u4159();
	}
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
	framePtr__system_u3605 = (*framePtr__system_u3605).prev;
}
N_LIB_PRIVATE N_NIMCALL(NU8*, foo__temp_u1)(void) {
	NU8* result;
	nimfr_("foo", "/home/runner/work/Nim/Nim/temp.nim");
	result = (NU8*)0;
	result = (&((NU8)0));
	popFrame();
	return result;
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
	NIM_BOOL* result;
	result = (NIM_BOOL*)0;
	result = (&nimInErrorMode__system_u3967);
	return result;
}
N_LIB_PRIVATE void PreMainInner(void) {
}
N_LIB_PRIVATE int cmdCount;
N_LIB_PRIVATE char** cmdLine;
N_LIB_PRIVATE char** gEnv;
N_LIB_PRIVATE void PreMain(void) {
#if 0
	void (*volatile inner)(void);
	inner = PreMainInner;
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000();
	(*inner)();
#else
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000();
	PreMainInner();
#endif
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
	NimMainModule();
}
N_CDECL(void, NimMain)(void) {
#if 0
	void (*volatile inner)(void);
	PreMain();
	inner = NimMainInner;
	(*inner)();
#else
	PreMain();
	NimMainInner();
#endif
}
int main(int argc, char** args, char** env) {
	cmdLine = args;
	cmdCount = argc;
	gEnv = env;
	NimMain();
	return nim_program_result;
}
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) {
{
	NimStringV2 colontmpD_;
	tyArray__nHXaesL0DJZHyVS07ARPRA T2_;
	NU8* T3_;
NIM_BOOL* nimErr_;
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
	colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
	T3_ = (NU8*)0;
	T3_ = foo__temp_u1();
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	colontmpD_ = repr__temp_u36(T3_);
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	T2_[0] = colontmpD_;
	echoBinSafe(T2_, 1);
	{
		LA1_:;
	}
	{
		if (colontmpD_.p && !(colontmpD_.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared(colontmpD_.p);
}
	}
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	BeforeRet_: ;
	nimTestErrorFlag();
	popFrame();
}
}

AST

nnkStmtList.newTree(
  nnkFuncDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      nnkPtrTy.newTree(
        nnkBracketExpr.newTree(
          newIdentNode("UncheckedArray"),
          newIdentNode("byte")
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkConstSection.newTree(
        nnkConstDef.newTree(
          newIdentNode("bar"),
          newEmptyNode(),
          nnkBracket.newTree(
            nnkDotExpr.newTree(
              newLit(0),
              newIdentNode("byte")
            )
          )
        )
      ),
      nnkCast.newTree(
        nnkPtrTy.newTree(
          nnkBracketExpr.newTree(
            newIdentNode("UncheckedArray"),
            newIdentNode("byte")
          )
        ),
        nnkCommand.newTree(
          newIdentNode("unsafeAddr"),
          nnkBracketExpr.newTree(
            newIdentNode("bar"),
            newLit(0)
          )
        )
      )
    )
  ),
  nnkCommand.newTree(
    newIdentNode("echo"),
    nnkPrefix.newTree(
      newIdentNode("$"),
      nnkCall.newTree(
        newIdentNode("repr"),
        nnkCall.newTree(
          newIdentNode("foo")
        )
      )
    )
  )
)
1.0.0 👎 FAIL

Output

Error: Command failed: nim c --gc:arc -d:nimArcDebug -d:nimArcIds  --run  -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --styleCheck:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
command line(1, 2) Error: 'none', 'boehm' or 'refc' expected, but 'arc' found

Stats

  • Started 2023-08-06T21:35:42
  • Finished 2023-08-06T21:35:42
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
#define nimfr_(proc, file) \
  TFrame FR_; \
  FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
  #define nimfrs_(proc, file, slots, length) \
    struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename;NI len;VarSlot s[slots];} FR_; \
    FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
  #define nimln_(n) \
    FR_.line = n;
  #define nimlf_(n, file) \
    FR_.line = n; FR_.filename = file;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
struct NimStrPayload {
	NI cap;
	NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
	NI len;
	NimStrPayload* p;
};
typedef NimStringV2 tyArray__nHXaesL0DJZHyVS07ARPRA[1];
typedef NU8 tyUncheckedArray__nMUrxcwM7yrVbfFpM3W4Sw[1];
N_LIB_PRIVATE N_NIMCALL(NimStringV2, repr__temp_u36)(NU8* x_p0);
N_LIB_PRIVATE N_NIMCALL(NU8*, foo__temp_u1)(void);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4159)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringV2* args_p0, NI args_p0Len_0);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
extern NIM_THREADVAR TFrame* framePtr__system_u3605;
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u3967;
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
	{
		if (!(framePtr__system_u3605 == ((TFrame*) NIM_NIL))) goto LA3_;
		(*s_p0).calldepth = ((NI16)0);
	}
	goto LA1_;
LA3_: ;
	{
		(*s_p0).calldepth = (NI16)((*framePtr__system_u3605).calldepth + ((NI16)1));
	}
LA1_: ;
	(*s_p0).prev = framePtr__system_u3605;
	framePtr__system_u3605 = s_p0;
	{
		if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
		callDepthLimitReached__system_u4159();
	}
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
	framePtr__system_u3605 = (*framePtr__system_u3605).prev;
}
N_LIB_PRIVATE N_NIMCALL(NU8*, foo__temp_u1)(void) {
	NU8* result;
	nimfr_("foo", "/home/runner/work/Nim/Nim/temp.nim");
	result = (NU8*)0;
	result = (&((NU8)0));
	popFrame();
	return result;
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
	NIM_BOOL* result;
	result = (NIM_BOOL*)0;
	result = (&nimInErrorMode__system_u3967);
	return result;
}
N_LIB_PRIVATE void PreMainInner(void) {
}
N_LIB_PRIVATE int cmdCount;
N_LIB_PRIVATE char** cmdLine;
N_LIB_PRIVATE char** gEnv;
N_LIB_PRIVATE void PreMain(void) {
#if 0
	void (*volatile inner)(void);
	inner = PreMainInner;
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000();
	(*inner)();
#else
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000();
	PreMainInner();
#endif
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
	NimMainModule();
}
N_CDECL(void, NimMain)(void) {
#if 0
	void (*volatile inner)(void);
	PreMain();
	inner = NimMainInner;
	(*inner)();
#else
	PreMain();
	NimMainInner();
#endif
}
int main(int argc, char** args, char** env) {
	cmdLine = args;
	cmdCount = argc;
	gEnv = env;
	NimMain();
	return nim_program_result;
}
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) {
{
	NimStringV2 colontmpD_;
	tyArray__nHXaesL0DJZHyVS07ARPRA T2_;
	NU8* T3_;
NIM_BOOL* nimErr_;
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
	colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
	T3_ = (NU8*)0;
	T3_ = foo__temp_u1();
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	colontmpD_ = repr__temp_u36(T3_);
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	T2_[0] = colontmpD_;
	echoBinSafe(T2_, 1);
	{
		LA1_:;
	}
	{
		if (colontmpD_.p && !(colontmpD_.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared(colontmpD_.p);
}
	}
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	BeforeRet_: ;
	nimTestErrorFlag();
	popFrame();
}
}

AST

nnkStmtList.newTree(
  nnkFuncDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      nnkPtrTy.newTree(
        nnkBracketExpr.newTree(
          newIdentNode("UncheckedArray"),
          newIdentNode("byte")
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkConstSection.newTree(
        nnkConstDef.newTree(
          newIdentNode("bar"),
          newEmptyNode(),
          nnkBracket.newTree(
            nnkDotExpr.newTree(
              newLit(0),
              newIdentNode("byte")
            )
          )
        )
      ),
      nnkCast.newTree(
        nnkPtrTy.newTree(
          nnkBracketExpr.newTree(
            newIdentNode("UncheckedArray"),
            newIdentNode("byte")
          )
        ),
        nnkCommand.newTree(
          newIdentNode("unsafeAddr"),
          nnkBracketExpr.newTree(
            newIdentNode("bar"),
            newLit(0)
          )
        )
      )
    )
  ),
  nnkCommand.newTree(
    newIdentNode("echo"),
    nnkPrefix.newTree(
      newIdentNode("$"),
      nnkCall.newTree(
        newIdentNode("repr"),
        nnkCall.newTree(
          newIdentNode("foo")
        )
      )
    )
  )
)
0.20.2 👎 FAIL

Output

Error: Command failed: nim c --gc:arc -d:nimArcDebug -d:nimArcIds  --run  -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --styleCheck:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
command line(1, 2) Error: 'none', 'boehm' or 'refc' expected, but 'arc' found

Stats

  • Started 2023-08-06T21:35:52
  • Finished 2023-08-06T21:35:52
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
#define nimfr_(proc, file) \
  TFrame FR_; \
  FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
  #define nimfrs_(proc, file, slots, length) \
    struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename;NI len;VarSlot s[slots];} FR_; \
    FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
  #define nimln_(n) \
    FR_.line = n;
  #define nimlf_(n, file) \
    FR_.line = n; FR_.filename = file;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
struct NimStrPayload {
	NI cap;
	NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
	NI len;
	NimStrPayload* p;
};
typedef NimStringV2 tyArray__nHXaesL0DJZHyVS07ARPRA[1];
typedef NU8 tyUncheckedArray__nMUrxcwM7yrVbfFpM3W4Sw[1];
N_LIB_PRIVATE N_NIMCALL(NimStringV2, repr__temp_u36)(NU8* x_p0);
N_LIB_PRIVATE N_NIMCALL(NU8*, foo__temp_u1)(void);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4159)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringV2* args_p0, NI args_p0Len_0);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
extern NIM_THREADVAR TFrame* framePtr__system_u3605;
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u3967;
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
	{
		if (!(framePtr__system_u3605 == ((TFrame*) NIM_NIL))) goto LA3_;
		(*s_p0).calldepth = ((NI16)0);
	}
	goto LA1_;
LA3_: ;
	{
		(*s_p0).calldepth = (NI16)((*framePtr__system_u3605).calldepth + ((NI16)1));
	}
LA1_: ;
	(*s_p0).prev = framePtr__system_u3605;
	framePtr__system_u3605 = s_p0;
	{
		if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
		callDepthLimitReached__system_u4159();
	}
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
	framePtr__system_u3605 = (*framePtr__system_u3605).prev;
}
N_LIB_PRIVATE N_NIMCALL(NU8*, foo__temp_u1)(void) {
	NU8* result;
	nimfr_("foo", "/home/runner/work/Nim/Nim/temp.nim");
	result = (NU8*)0;
	result = (&((NU8)0));
	popFrame();
	return result;
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
	NIM_BOOL* result;
	result = (NIM_BOOL*)0;
	result = (&nimInErrorMode__system_u3967);
	return result;
}
N_LIB_PRIVATE void PreMainInner(void) {
}
N_LIB_PRIVATE int cmdCount;
N_LIB_PRIVATE char** cmdLine;
N_LIB_PRIVATE char** gEnv;
N_LIB_PRIVATE void PreMain(void) {
#if 0
	void (*volatile inner)(void);
	inner = PreMainInner;
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000();
	(*inner)();
#else
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000();
	PreMainInner();
#endif
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
	NimMainModule();
}
N_CDECL(void, NimMain)(void) {
#if 0
	void (*volatile inner)(void);
	PreMain();
	inner = NimMainInner;
	(*inner)();
#else
	PreMain();
	NimMainInner();
#endif
}
int main(int argc, char** args, char** env) {
	cmdLine = args;
	cmdCount = argc;
	gEnv = env;
	NimMain();
	return nim_program_result;
}
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) {
{
	NimStringV2 colontmpD_;
	tyArray__nHXaesL0DJZHyVS07ARPRA T2_;
	NU8* T3_;
NIM_BOOL* nimErr_;
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
	colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
	T3_ = (NU8*)0;
	T3_ = foo__temp_u1();
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	colontmpD_ = repr__temp_u36(T3_);
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	T2_[0] = colontmpD_;
	echoBinSafe(T2_, 1);
	{
		LA1_:;
	}
	{
		if (colontmpD_.p && !(colontmpD_.p->cap & NIM_STRLIT_FLAG)) {
 deallocShared(colontmpD_.p);
}
	}
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	BeforeRet_: ;
	nimTestErrorFlag();
	popFrame();
}
}

AST

nnkStmtList.newTree(
  nnkFuncDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      nnkPtrTy.newTree(
        nnkBracketExpr.newTree(
          newIdentNode("UncheckedArray"),
          newIdentNode("byte")
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkConstSection.newTree(
        nnkConstDef.newTree(
          newIdentNode("bar"),
          newEmptyNode(),
          nnkBracket.newTree(
            nnkDotExpr.newTree(
              newLit(0),
              newIdentNode("byte")
            )
          )
        )
      ),
      nnkCast.newTree(
        nnkPtrTy.newTree(
          nnkBracketExpr.newTree(
            newIdentNode("UncheckedArray"),
            newIdentNode("byte")
          )
        ),
        nnkCommand.newTree(
          newIdentNode("unsafeAddr"),
          nnkBracketExpr.newTree(
            newIdentNode("bar"),
            newLit(0)
          )
        )
      )
    )
  ),
  nnkCommand.newTree(
    newIdentNode("echo"),
    nnkPrefix.newTree(
      newIdentNode("$"),
      nnkCall.newTree(
        newIdentNode("repr"),
        nnkCall.newTree(
          newIdentNode("foo")
        )
      )
    )
  )
)
Stats
  • GCC (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0
  • LibC (Ubuntu GLIBC 2.35-0ubuntu3.1) 2.35
  • Valgrind 3.18.1
  • NodeJS 18.17.0
  • Linux 5.15.0-1042-
  • Created 2023-08-06T21:34:27Z
  • Issue Comments 3
  • Commands nim c --gc:arc -d:nimArcDebug -d:nimArcIds --run -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --styleCheck:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

🤖 Bug found in 49 minutes bisecting 8 commits at 0 commits per second.

narimiran pushed a commit that referenced this issue Oct 28, 2024
narimiran pushed a commit that referenced this issue Oct 28, 2024
fixes #22389;
fixes #19840

(cherry picked from commit 5c5e7a9)
(cherry picked from commit 00e39185f1d59597d17b69bbccf8879e3427f928)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants