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

push-ing pragma exportc generates invalid C identifiers #22913

Closed
turbo opened this issue Nov 5, 2023 · 8 comments · Fixed by #22941
Closed

push-ing pragma exportc generates invalid C identifiers #22913

turbo opened this issue Nov 5, 2023 · 8 comments · Fixed by #22941
Assignees

Comments

@turbo
Copy link

turbo commented Nov 5, 2023

Description

Compiles fine

type r* = object

proc foo(): r {.exportc: "$1".} =
  echo result

Fails:

type r* = object

{.push exportc: "$1".}
proc foo(): r =
  echo result
{.pop.}

Compilation command:

nim -r c repro.nim

Nim Version

Nim Compiler Version 2.0.0 [MacOSX: arm64]
Compiled at 2023-08-02
Copyright (c) 2006-2023 by Andreas Rumpf

active boot switches: -d:release

Current Output

Fails with an invalid generated C symbol:

CC: ../../nim-2.0.0/lib/std/objectdollar.nim
/Users/turbo/.cache/nim/repro_d/@m..@s..@snim-2.0.0@slib@sstd@sobjectdollar.nim.c:142:10: error: expected ';' at end of declaration
        NI count`gensym1;
                ^
                ;
/Users/turbo/.cache/nim/repro_d/@m..@s..@snim-2.0.0@slib@sstd@sobjectdollar.nim.c:149:7: error: expected ';' after expression
        count`gensym1 = ((NI)0);
             ^
             ;
/Users/turbo/.cache/nim/repro_d/@m..@s..@snim-2.0.0@slib@sstd@sobjectdollar.nim.c:149:7: error: expected expression

Expected Output

none, successful compilation

Possible Solution

No response

Additional Information

No response

@metagn
Copy link
Collaborator

metagn commented Nov 6, 2023

It seems like push exportc leaks into the generic instantiation of $ which is pretty undesirable.

@ringabout ringabout self-assigned this Nov 6, 2023
@nim-lang nim-lang deleted a comment from github-actions bot Nov 14, 2023
@ringabout
Copy link
Member

!nim c

type r* = object
{.push exportc: "$1".}
proc foo(): r =
  echo result
{.pop.}

Copy link
Contributor

🐧 Linux bisect by @ringabout (member)
devel 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints: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/@m..@s..@s..@s.choosenim@stoolchains@snim-@hdevel@slib@sstd@sobjectdollar.nim.c: In function ‘dollar___temp_u22’:
/home/runner/work/Nim/Nim/@m..@s..@s..@s.choosenim@stoolchains@snim-@hdevel@slib@sstd@sobjectdollar.nim.c:118:17: error: stray ‘`’ in program
  118 |         NI count`gensym1;
      |                 ^
/home/runner/work/Nim/Nim/@m..@s..@s..@s.choosenim@stoolchains@snim-@hdevel@slib@sstd@sobjectdollar.nim.c:118:18: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gensym1’
  118 |         NI count`gensym1;
      |                  ^~~~~~~
/home/runner/work/Nim/Nim/@m..@s..@s..@s.choosenim@stoolchains@snim-@hdevel@slib@sstd@sobjectdollar.nim.c:118:18: error: ‘gensym1’ undeclared (first use in this function)
/home/runner/work/Nim/Nim/@m..@s..@s..@s.choosenim@stoolchains@snim-@hdevel@slib@sstd@sobjectdollar.nim.c:118:18: note: each undeclared identifier is reported only once for each function it appears in
compilation terminated due to -fmax-errors=3.
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/@m..@s..@s..@s.choosenim@stoolchains@snim-@hdevel@slib@sstd@sobjectdollar.nim.c.o /home/runner/work/Nim/Nim/@m..@s..@s..@s.choosenim@stoolchains@snim-@hdevel@slib@sstd@sobjectdollar.nim.c' failed with exit code: 1


assertions.nim(34)       raiseAssert
Error: unhandled exception: errGenerated [AssertionDefect]

IR

Compiled filesize 0 bytes (0 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#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 tyObject_r__k69bgTG9anxUFadPjWOwGmWQ tyObject_r__k69bgTG9anxUFadPjWOwGmWQ;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
struct tyObject_r__k69bgTG9anxUFadPjWOwGmWQ {
 char dummy;
};
struct NimStrPayload {
 NI cap;
 NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
 NI len;
 NimStrPayload* p;
};
typedef NimStringV2 tyArray__nHXaesL0DJZHyVS07ARPRA[1];
N_LIB_PRIVATE N_NIMCALL(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ, foo)(void);
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1);
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, dollar___temp_u22)(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ x_p0);
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(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4661)(void);
static N_INLINE(void, popFrame)(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 NIM_BOOL nimInErrorMode__system_u4445;
extern NIM_THREADVAR TFrame* framePtr__system_u4048;
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2) {
 void* T1_;
 T1_ = (void*)0;
 T1_ = memset(a_p0, v_p1, ((size_t) (size_p2)));
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
 NIM_BOOL* result;
 result = (&nimInErrorMode__system_u4445);
 return result;
}
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
 nimSetMem__systemZmemory_u7(p_p0, ((int)0), size_p1);
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }BeforeRet_: ;
}
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
 {
  if (!(framePtr__system_u4048 == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s_p0).calldepth = ((NI16)0);
 }
 goto LA1_;
LA3_: ;
 {
  (*s_p0).calldepth = (NI16)((*framePtr__system_u4048).calldepth + ((NI16)1));
 }
LA1_: ;
 (*s_p0).prev = framePtr__system_u4048;
 framePtr__system_u4048 = s_p0;
 {
  if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
  callDepthLimitReached__system_u4661();
 }
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__system_u4048 = (*framePtr__system_u4048).prev;
}
N_LIB_PRIVATE N_NIMCALL(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ, foo)(void) {
 tyObject_r__k69bgTG9anxUFadPjWOwGmWQ result;
 NimStringV2 colontmpD_;
 tyArray__nHXaesL0DJZHyVS07ARPRA T2_;
NIM_BOOL* nimErr_;
 nimfr_("foo", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
 nimZeroMem((void*)(&result), sizeof(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ));
 colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
 colontmpD_ = dollar___temp_u22(result);
 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_: ;
 popFrame();
 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) {
{
 nimTestErrorFlag();
}
}

Stats

  • Started 2023-11-14T10:56:32
  • Finished 2023-11-14T10:56:33
  • Duration

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      nnkPostfix.newTree(
        newIdentNode("*"),
        newIdentNode("r")
      ),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        newEmptyNode()
      )
    )
  ),
  nnkPragma.newTree(
    newIdentNode("push"),
    nnkExprColonExpr.newTree(
      newIdentNode("exportc"),
      newLit("$1")
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("r")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("result")
      )
    )
  ),
  nnkPragma.newTree(
    newIdentNode("pop")
  )
)
stable 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints: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/@m..@s..@s..@s.choosenim@stoolchains@snim-2.0.0@slib@sstd@sobjectdollar.nim.c: In function ‘dollar___temp_u22’:
/home/runner/work/Nim/Nim/@m..@s..@s..@s.choosenim@stoolchains@snim-2.0.0@slib@sstd@sobjectdollar.nim.c:117:17: error: stray ‘`’ in program
  117 |         NI count`gensym1;
      |                 ^
/home/runner/work/Nim/Nim/@m..@s..@s..@s.choosenim@stoolchains@snim-2.0.0@slib@sstd@sobjectdollar.nim.c:117:18: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gensym1’
  117 |         NI count`gensym1;
      |                  ^~~~~~~
/home/runner/work/Nim/Nim/@m..@s..@s..@s.choosenim@stoolchains@snim-2.0.0@slib@sstd@sobjectdollar.nim.c:117:18: error: ‘gensym1’ undeclared (first use in this function)
/home/runner/work/Nim/Nim/@m..@s..@s..@s.choosenim@stoolchains@snim-2.0.0@slib@sstd@sobjectdollar.nim.c:117:18: note: each undeclared identifier is reported only once for each function it appears in
compilation terminated due to -fmax-errors=3.
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/@m..@s..@s..@s.choosenim@stoolchains@snim-2.0.0@slib@sstd@sobjectdollar.nim.c.o /home/runner/work/Nim/Nim/@m..@s..@s..@s.choosenim@stoolchains@snim-2.0.0@slib@sstd@sobjectdollar.nim.c' failed with exit code: 1


assertions.nim(34)       raiseAssert
Error: unhandled exception: options.nim(664, 5) `false` errGenerated [AssertionDefect]

IR

Compiled filesize 0 bytes (0 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#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 tyObject_r__k69bgTG9anxUFadPjWOwGmWQ tyObject_r__k69bgTG9anxUFadPjWOwGmWQ;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
struct tyObject_r__k69bgTG9anxUFadPjWOwGmWQ {
 char dummy;
};
struct NimStrPayload {
 NI cap;
 NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
 NI len;
 NimStrPayload* p;
};
typedef NimStringV2 tyArray__nHXaesL0DJZHyVS07ARPRA[1];
N_LIB_PRIVATE N_NIMCALL(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ, foo)(void);
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1);
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, dollar___temp_u22)(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ x_p0);
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(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4607)(void);
static N_INLINE(void, popFrame)(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 NIM_BOOL nimInErrorMode__system_u4389;
extern NIM_THREADVAR TFrame* framePtr__system_u4006;
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2) {
 void* T1_;
 T1_ = (void*)0;
 T1_ = memset(a_p0, v_p1, ((size_t) (size_p2)));
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
 NIM_BOOL* result;
 result = (NIM_BOOL*)0;
 result = (&nimInErrorMode__system_u4389);
 return result;
}
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
 nimSetMem__systemZmemory_u7(p_p0, ((int)0), size_p1);
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }BeforeRet_: ;
}
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
 {
  if (!(framePtr__system_u4006 == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s_p0).calldepth = ((NI16)0);
 }
 goto LA1_;
LA3_: ;
 {
  (*s_p0).calldepth = (NI16)((*framePtr__system_u4006).calldepth + ((NI16)1));
 }
LA1_: ;
 (*s_p0).prev = framePtr__system_u4006;
 framePtr__system_u4006 = s_p0;
 {
  if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
  callDepthLimitReached__system_u4607();
 }
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__system_u4006 = (*framePtr__system_u4006).prev;
}
N_LIB_PRIVATE N_NIMCALL(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ, foo)(void) {
 tyObject_r__k69bgTG9anxUFadPjWOwGmWQ result;
 NimStringV2 colontmpD_;
 tyArray__nHXaesL0DJZHyVS07ARPRA T2_;
NIM_BOOL* nimErr_;
 nimfr_("foo", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
 nimZeroMem((void*)(&result), sizeof(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ));
 colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
 colontmpD_ = dollar___temp_u22(result);
 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_: ;
 popFrame();
 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) {
{
 nimTestErrorFlag();
}
}

Stats

  • Started 2023-11-14T10:56:33
  • Finished 2023-11-14T10:56:33
  • Duration

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      nnkPostfix.newTree(
        newIdentNode("*"),
        newIdentNode("r")
      ),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        newEmptyNode()
      )
    )
  ),
  nnkPragma.newTree(
    newIdentNode("push"),
    nnkExprColonExpr.newTree(
      newIdentNode("exportc"),
      newLit("$1")
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("r")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("result")
      )
    )
  ),
  nnkPragma.newTree(
    newIdentNode("pop")
  )
)
2.0.0 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints: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/@m..@s..@s..@s.choosenim@stoolchains@snim-2.0.0@slib@sstd@sobjectdollar.nim.c: In function ‘dollar___temp_u22’:
/home/runner/work/Nim/Nim/@m..@s..@s..@s.choosenim@stoolchains@snim-2.0.0@slib@sstd@sobjectdollar.nim.c:117:17: error: stray ‘`’ in program
  117 |         NI count`gensym1;
      |                 ^
/home/runner/work/Nim/Nim/@m..@s..@s..@s.choosenim@stoolchains@snim-2.0.0@slib@sstd@sobjectdollar.nim.c:117:18: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gensym1’
  117 |         NI count`gensym1;
      |                  ^~~~~~~
/home/runner/work/Nim/Nim/@m..@s..@s..@s.choosenim@stoolchains@snim-2.0.0@slib@sstd@sobjectdollar.nim.c:117:18: error: ‘gensym1’ undeclared (first use in this function)
/home/runner/work/Nim/Nim/@m..@s..@s..@s.choosenim@stoolchains@snim-2.0.0@slib@sstd@sobjectdollar.nim.c:117:18: note: each undeclared identifier is reported only once for each function it appears in
compilation terminated due to -fmax-errors=3.
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/@m..@s..@s..@s.choosenim@stoolchains@snim-2.0.0@slib@sstd@sobjectdollar.nim.c.o /home/runner/work/Nim/Nim/@m..@s..@s..@s.choosenim@stoolchains@snim-2.0.0@slib@sstd@sobjectdollar.nim.c' failed with exit code: 1


assertions.nim(34)       raiseAssert
Error: unhandled exception: options.nim(664, 5) `false` errGenerated [AssertionDefect]

IR

Compiled filesize 0 bytes (0 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#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 tyObject_r__k69bgTG9anxUFadPjWOwGmWQ tyObject_r__k69bgTG9anxUFadPjWOwGmWQ;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
struct tyObject_r__k69bgTG9anxUFadPjWOwGmWQ {
 char dummy;
};
struct NimStrPayload {
 NI cap;
 NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
 NI len;
 NimStrPayload* p;
};
typedef NimStringV2 tyArray__nHXaesL0DJZHyVS07ARPRA[1];
N_LIB_PRIVATE N_NIMCALL(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ, foo)(void);
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1);
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, dollar___temp_u22)(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ x_p0);
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(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4607)(void);
static N_INLINE(void, popFrame)(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 NIM_BOOL nimInErrorMode__system_u4389;
extern NIM_THREADVAR TFrame* framePtr__system_u4006;
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2) {
 void* T1_;
 T1_ = (void*)0;
 T1_ = memset(a_p0, v_p1, ((size_t) (size_p2)));
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
 NIM_BOOL* result;
 result = (NIM_BOOL*)0;
 result = (&nimInErrorMode__system_u4389);
 return result;
}
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
 nimSetMem__systemZmemory_u7(p_p0, ((int)0), size_p1);
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }BeforeRet_: ;
}
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
 {
  if (!(framePtr__system_u4006 == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s_p0).calldepth = ((NI16)0);
 }
 goto LA1_;
LA3_: ;
 {
  (*s_p0).calldepth = (NI16)((*framePtr__system_u4006).calldepth + ((NI16)1));
 }
LA1_: ;
 (*s_p0).prev = framePtr__system_u4006;
 framePtr__system_u4006 = s_p0;
 {
  if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
  callDepthLimitReached__system_u4607();
 }
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__system_u4006 = (*framePtr__system_u4006).prev;
}
N_LIB_PRIVATE N_NIMCALL(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ, foo)(void) {
 tyObject_r__k69bgTG9anxUFadPjWOwGmWQ result;
 NimStringV2 colontmpD_;
 tyArray__nHXaesL0DJZHyVS07ARPRA T2_;
NIM_BOOL* nimErr_;
 nimfr_("foo", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
 nimZeroMem((void*)(&result), sizeof(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ));
 colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
 colontmpD_ = dollar___temp_u22(result);
 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_: ;
 popFrame();
 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) {
{
 nimTestErrorFlag();
}
}

Stats

  • Started 2023-11-14T10:56:34
  • Finished 2023-11-14T10:56:34
  • Duration

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      nnkPostfix.newTree(
        newIdentNode("*"),
        newIdentNode("r")
      ),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        newEmptyNode()
      )
    )
  ),
  nnkPragma.newTree(
    newIdentNode("push"),
    nnkExprColonExpr.newTree(
      newIdentNode("exportc"),
      newLit("$1")
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("r")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("result")
      )
    )
  ),
  nnkPragma.newTree(
    newIdentNode("pop")
  )
)
1.6.14 👍 OK

Output


IR

Compiled filesize 95.97 Kb (98,272 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#  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, file) \
 FR_.line = n; FR_.filename = file;
typedef struct tyObject_r__k69bgTG9anxUFadPjWOwGmWQ tyObject_r__k69bgTG9anxUFadPjWOwGmWQ;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
struct tyObject_r__k69bgTG9anxUFadPjWOwGmWQ {
char dummy;
};
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef NimStringDesc* tyArray__nHXaesL0DJZHyVS07ARPRA[1];
N_LIB_PRIVATE N_NIMCALL(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ, foo)(void);
static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem__systemZmemory_7)(void* a, int v, NI size);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, dollar___temp_17)(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ x);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringDesc** args, NI argsLen_0);
static N_INLINE(void, nimFrame)(TFrame* s);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_2997)(void);
static N_INLINE(void, popFrame)(void);
static N_INLINE(void, initStackBottomWith)(void* locals);
N_LIB_PRIVATE N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_DatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
extern TFrame* framePtr__system_2564;
extern TFrame* framePtr__system_2564;
extern TFrame* framePtr__system_2564;
extern TFrame* framePtr__system_2564;
extern TFrame* framePtr__system_2564;
extern TFrame* framePtr__system_2564;
static N_INLINE(void, nimSetMem__systemZmemory_7)(void* a, int v, NI size) {
 void* T1_;
 T1_ = (void*)0;
 T1_ = memset(a, v, ((size_t) (size)));
}
static N_INLINE(void, nimZeroMem)(void* p, NI size) {
 nimSetMem__systemZmemory_7(p, ((int) 0), size);
}
static N_INLINE(void, nimFrame)(TFrame* s) {
 {
  if (!(framePtr__system_2564 == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s).calldepth = ((NI16) 0);
 }
 goto LA1_;
 LA3_: ;
 {
  (*s).calldepth = (NI16)((*framePtr__system_2564).calldepth + ((NI16) 1));
 }
 LA1_: ;
 (*s).prev = framePtr__system_2564;
 framePtr__system_2564 = s;
 {
  if (!((*s).calldepth == ((NI16) 2000))) goto LA8_;
  callDepthLimitReached__system_2997();
 }
 LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__system_2564 = (*framePtr__system_2564).prev;
}
N_LIB_PRIVATE N_NIMCALL(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ, foo)(void) {
 tyObject_r__k69bgTG9anxUFadPjWOwGmWQ result;
 tyArray__nHXaesL0DJZHyVS07ARPRA T1_;
 nimfr_("foo", "/home/runner/work/Nim/Nim/temp.nim");
 nimZeroMem((void*)(&result), sizeof(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ));
 nimZeroMem((void*)T1_, sizeof(tyArray__nHXaesL0DJZHyVS07ARPRA));
 T1_[0] = dollar___temp_17(result);
 echoBinSafe(T1_, 1);
 popFrame();
 return result;
}
static N_INLINE(void, initStackBottomWith)(void* locals) {
 nimGC_setStackBottom(locals);
}
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) {
 void (*volatile inner)(void);
 inner = PreMainInner;
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_DatInit000();
 initStackBottomWith((void *)&inner);
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_Init000();
 (*inner)();
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
 NimMainModule();
}
N_CDECL(void, NimMain)(void) {
 void (*volatile inner)(void);
 PreMain();
 inner = NimMainInner;
 initStackBottomWith((void *)&inner);
 (*inner)();
}
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) {
{
}
}

Stats

  • Started 2023-11-14T10:56:36
  • Finished 2023-11-14T10:56:37
  • Duration
1.4.8 👍 OK

Output


IR

Compiled filesize 92.35 Kb (94,568 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#  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, file) \
 FR_.line = n; FR_.filename = file;
typedef struct tyObject_r__K5x2PVxkVglpEfIjXIUwNg tyObject_r__K5x2PVxkVglpEfIjXIUwNg;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
struct tyObject_r__K5x2PVxkVglpEfIjXIUwNg {
char dummy;
};
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef NimStringDesc* tyArray__nHXaesL0DJZHyVS07ARPRA[1];
N_LIB_PRIVATE N_NIMCALL(tyObject_r__K5x2PVxkVglpEfIjXIUwNg, foo)(void);
static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, dollar___amsefZ1s2PW9aEvuypph2eQ)(tyObject_r__K5x2PVxkVglpEfIjXIUwNg x);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringDesc** args, NI argsLen_0);
static N_INLINE(void, nimFrame)(TFrame* s);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__mMRdr4sgmnykA9aWeM9aDZlw)(void);
static N_INLINE(void, popFrame)(void);
static N_INLINE(void, initStackBottomWith)(void* locals);
N_LIB_PRIVATE N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom);
N_LIB_PRIVATE N_NIMCALL(void, systemDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size) {
 void* T1_;
 T1_ = (void*)0;
 T1_ = memset(a, v, ((size_t) (size)));
}
static N_INLINE(void, nimZeroMem)(void* p, NI size) {
 nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory(p, ((int) 0), size);
}
static N_INLINE(void, nimFrame)(TFrame* s) {
 {
  if (!(framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s).calldepth = ((NI16) 0);
 }
 goto LA1_;
 LA3_: ;
 {
  (*s).calldepth = (NI16)((*framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw).calldepth + ((NI16) 1));
 }
 LA1_: ;
 (*s).prev = framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
 framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw = s;
 {
  if (!((*s).calldepth == ((NI16) 2000))) goto LA8_;
  callDepthLimitReached__mMRdr4sgmnykA9aWeM9aDZlw();
 }
 LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw = (*framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw).prev;
}
N_LIB_PRIVATE N_NIMCALL(tyObject_r__K5x2PVxkVglpEfIjXIUwNg, foo)(void) {
 tyObject_r__K5x2PVxkVglpEfIjXIUwNg result;
 tyArray__nHXaesL0DJZHyVS07ARPRA T1_;
 nimfr_("foo", "/home/runner/work/Nim/Nim/temp.nim");
 nimZeroMem((void*)(&result), sizeof(tyObject_r__K5x2PVxkVglpEfIjXIUwNg));
 nimZeroMem((void*)T1_, sizeof(tyArray__nHXaesL0DJZHyVS07ARPRA));
 T1_[0] = dollar___amsefZ1s2PW9aEvuypph2eQ(result);
 echoBinSafe(T1_, 1);
 popFrame();
 return result;
}
static N_INLINE(void, initStackBottomWith)(void* locals) {
 nimGC_setStackBottom(locals);
}
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) {
 void (*volatile inner)(void);
 inner = PreMainInner;
 systemDatInit000();
 initStackBottomWith((void *)&inner);
 systemInit000();
 (*inner)();
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
 NimMainModule();
}
N_CDECL(void, NimMain)(void) {
 void (*volatile inner)(void);
 PreMain();
 inner = NimMainInner;
 initStackBottomWith((void *)&inner);
 (*inner)();
}
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) {
{
}
}

Stats

  • Started 2023-11-14T10:56:39
  • Finished 2023-11-14T10:56:39
  • Duration
1.2.18 👍 OK

Output


IR

Compiled filesize 92.08 Kb (94,288 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#  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, file) \
 FR_.line = n; FR_.filename = file;
typedef struct tyObject_r__K5x2PVxkVglpEfIjXIUwNg tyObject_r__K5x2PVxkVglpEfIjXIUwNg;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
struct tyObject_r__K5x2PVxkVglpEfIjXIUwNg {
char dummy;
};
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef NimStringDesc* tyArray__nHXaesL0DJZHyVS07ARPRA[1];
N_LIB_PRIVATE N_NIMCALL(tyObject_r__K5x2PVxkVglpEfIjXIUwNg, foo)(void);
static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, dollar___amsefZ1s2PW9aEvuypph2eQ)(tyObject_r__K5x2PVxkVglpEfIjXIUwNg x);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringDesc** args, NI argsLen_0);
static N_INLINE(void, nimFrame)(TFrame* s);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__mMRdr4sgmnykA9aWeM9aDZlw)(void);
static N_INLINE(void, popFrame)(void);
static N_INLINE(void, initStackBottomWith)(void* locals);
N_LIB_PRIVATE N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom);
N_LIB_PRIVATE N_NIMCALL(void, systemDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size) {
 void* T1_;
 T1_ = (void*)0;
 T1_ = memset(a, v, ((size_t) (size)));
}
static N_INLINE(void, nimZeroMem)(void* p, NI size) {
 nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory(p, ((int) 0), size);
}
static N_INLINE(void, nimFrame)(TFrame* s) {
 {
  if (!(framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw == NIM_NIL)) goto LA3_;
  (*s).calldepth = ((NI16) 0);
 }
 goto LA1_;
 LA3_: ;
 {
  (*s).calldepth = (NI16)((*framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw).calldepth + ((NI16) 1));
 }
 LA1_: ;
 (*s).prev = framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
 framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw = s;
 {
  if (!((*s).calldepth == ((NI16) (((NI) 2000))))) goto LA8_;
  callDepthLimitReached__mMRdr4sgmnykA9aWeM9aDZlw();
 }
 LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw = (*framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw).prev;
}
N_LIB_PRIVATE N_NIMCALL(tyObject_r__K5x2PVxkVglpEfIjXIUwNg, foo)(void) {
 tyObject_r__K5x2PVxkVglpEfIjXIUwNg result;
 tyArray__nHXaesL0DJZHyVS07ARPRA T1_;
 nimfr_("foo", "/home/runner/work/Nim/Nim/temp.nim");
 nimZeroMem((void*)(&result), sizeof(tyObject_r__K5x2PVxkVglpEfIjXIUwNg));
 nimZeroMem((void*)T1_, sizeof(tyArray__nHXaesL0DJZHyVS07ARPRA));
 T1_[0] = dollar___amsefZ1s2PW9aEvuypph2eQ(result);
 echoBinSafe(T1_, 1);
 popFrame();
 return result;
}
static N_INLINE(void, initStackBottomWith)(void* locals) {
 nimGC_setStackBottom(locals);
}
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) {
 void (*volatile inner)(void);
 inner = PreMainInner;
 systemDatInit000();
 initStackBottomWith((void *)&inner);
 systemInit000();
 (*inner)();
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
 NimMainModule();
}
N_CDECL(void, NimMain)(void) {
 void (*volatile inner)(void);
 PreMain();
 inner = NimMainInner;
 initStackBottomWith((void *)&inner);
 (*inner)();
}
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) {
{
}
}

Stats

  • Started 2023-11-14T10:56:41
  • Finished 2023-11-14T10:56:41
  • Duration
1.0.10 👍 OK

Output


IR

Compiled filesize 87.20 Kb (89,288 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#  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, file) \
 FR_.line = n; FR_.filename = file;
typedef struct tyObject_r__K5x2PVxkVglpEfIjXIUwNg tyObject_r__K5x2PVxkVglpEfIjXIUwNg;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
struct tyObject_r__K5x2PVxkVglpEfIjXIUwNg {
char dummy;
};
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef NimStringDesc* tyArray__nHXaesL0DJZHyVS07ARPRA[1];
N_NIMCALL(tyObject_r__K5x2PVxkVglpEfIjXIUwNg, foo)(void);
static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, dollar___amsefZ1s2PW9aEvuypph2eQ)(tyObject_r__K5x2PVxkVglpEfIjXIUwNg x);
N_NIMCALL(void, echoBinSafe)(NimStringDesc** args, NI argsLen_0);
static N_INLINE(void, nimFrame)(TFrame* s);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__mMRdr4sgmnykA9aWeM9aDZlw)(void);
static N_INLINE(void, popFrame)(void);
static N_INLINE(void, initStackBottomWith)(void* locals);
N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom);
N_LIB_PRIVATE N_NIMCALL(void, systemDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size) {	void* T1_;
 T1_ = (void*)0;
 T1_ = memset(a, v, ((size_t) (size)));
}
static N_INLINE(void, nimZeroMem)(void* p, NI size) {	nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory(p, ((int) 0), size);
}
static N_INLINE(void, nimFrame)(TFrame* s) {	NI T1_;
 T1_ = (NI)0;
 {
  if (!(framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw == NIM_NIL)) goto LA4_;
  T1_ = ((NI) 0);
 }
 goto LA2_;
 LA4_: ;
 {
  T1_ = ((NI) ((NI16)((*framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw).calldepth + ((NI16) 1))));
 }
 LA2_: ;
 (*s).calldepth = ((NI16) (T1_));
 (*s).prev = framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
 framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw = s;
 {
  if (!((*s).calldepth == ((NI16) (((NI) 2000))))) goto LA9_;
  callDepthLimitReached__mMRdr4sgmnykA9aWeM9aDZlw();
 }
 LA9_: ;
}
static N_INLINE(void, popFrame)(void) {	framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw = (*framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw).prev;
}
N_NIMCALL(tyObject_r__K5x2PVxkVglpEfIjXIUwNg, foo)(void) {	tyObject_r__K5x2PVxkVglpEfIjXIUwNg result;
 tyArray__nHXaesL0DJZHyVS07ARPRA T1_;
 nimfr_("foo", "/home/runner/work/Nim/Nim/temp.nim");
 nimZeroMem((void*)(&result), sizeof(tyObject_r__K5x2PVxkVglpEfIjXIUwNg));
 nimZeroMem((void*)T1_, sizeof(tyArray__nHXaesL0DJZHyVS07ARPRA));
 T1_[0] = dollar___amsefZ1s2PW9aEvuypph2eQ(result);
 echoBinSafe(T1_, 1);
 popFrame();
 return result;
}
static N_INLINE(void, initStackBottomWith)(void* locals) {	nimGC_setStackBottom(locals);
}
void PreMainInner(void) {
}
int cmdCount;
char** cmdLine;
char** gEnv;
void PreMain(void) {
 void (*volatile inner)(void);
 inner = PreMainInner;
 systemDatInit000();
 initStackBottomWith((void *)&inner);
 systemInit000();
 (*inner)();
}
N_CDECL(void, NimMainInner)(void) {
 NimMainModule();
}
N_CDECL(void, NimMain)(void) {
 void (*volatile inner)(void);
 PreMain();
 inner = NimMainInner;
 initStackBottomWith((void *)&inner);
 (*inner)();
}
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) {
{
}
}

Stats

  • Started 2023-11-14T10:56:43
  • Finished 2023-11-14T10:56:43
  • Duration
#b8dc58d88 ➡️ 🐛

Diagnostics

metagn introduced a bug at 2022-08-24 10:44:16 +0300 on commit #b8dc58d88 with message:

test removing dollar for objects out of system (#20242)

* test removing dollar for objects out of system

* test & fixes

* fix bootstrap

* use nimPreviewSlimSystem, test stdlib category

* fix test

The bug is in the files:

compiler/ast.nim
compiler/passaux.nim
lib/pure/asyncfutures.nim
lib/std/objectdollar.nim
lib/std/private/miscdollars.nim
lib/system/dollars.nim
tests/stdlib/tobjectdollar.nim
tests/stdlib/toptions.nim
tests/stdlib/tstrformat.nim

The bug can be in the commits:

(Diagnostics sometimes off-by-one).

Stats
  • GCC 11.4.0
  • Clang 14.0.0
  • NodeJS 18.2
  • Created 2023-11-14T10:56:04Z
  • Comments 2
  • Commands nim c --run -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints: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 1923 commits at 39 commits per second

@ringabout
Copy link
Member

Thought my PR caused the regression. It seems to be a pre-existing problem. #b8dc58d88 is the superifical reason, which de facto exposed a problem of templates/generics expansion, which might not handle the push pragmas well.

@ringabout
Copy link
Member

!nim c

type r* = object

template std[T](x: T) =
  let ttt {.used.} = x
  result = $ttt

proc bar[T](x: T): string =
  # let today {.used.} = 12
  # block:
  #   let today = 623.5
  #   echo today
  std(x)

{.push exportc: "$1".}
proc foo(): r =
  let s = bar(123)
{.pop.}

echo foo()

Copy link
Contributor

🐧 Linux bisect by @ringabout (member)
devel 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints: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/@mtemp.nim.c: In function ‘bar__temp_u12’:
/home/runner/work/Nim/Nim/@mtemp.nim.c:109:15: error: stray ‘`’ in program
  109 |         NI ttt`gensym0;
      |               ^
/home/runner/work/Nim/Nim/@mtemp.nim.c:109:16: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gensym0’
  109 |         NI ttt`gensym0;
      |                ^~~~~~~
/home/runner/work/Nim/Nim/@mtemp.nim.c:109:16: error: ‘gensym0’ undeclared (first use in this function)
/home/runner/work/Nim/Nim/@mtemp.nim.c:109:16: note: each undeclared identifier is reported only once for each function it appears in
compilation terminated due to -fmax-errors=3.
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


assertions.nim(34)       raiseAssert
Error: unhandled exception: errGenerated [AssertionDefect]

IR

Compiled filesize 0 bytes (0 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#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;
typedef struct tyObject_r__k69bgTG9anxUFadPjWOwGmWQ tyObject_r__k69bgTG9anxUFadPjWOwGmWQ;
struct NimStrPayload {
 NI cap;
 NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
 NI len;
 NimStrPayload* p;
};
struct tyObject_r__k69bgTG9anxUFadPjWOwGmWQ {
 char dummy;
};
typedef NimStringV2 tyArray__nHXaesL0DJZHyVS07ARPRA[1];
N_LIB_PRIVATE N_NIMCALL(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ, foo)(void);
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1);
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, bar__temp_u12)(NI x_p0);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, dollar___systemZdollars_u8)(NI x_p0);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4661)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, dollar___temp_u38)(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ x_p0);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringV2* args_p0, NI args_p0Len_0);
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 NIM_BOOL nimInErrorMode__system_u4445;
extern NIM_THREADVAR TFrame* framePtr__system_u4048;
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2) {
 void* T1_;
 T1_ = (void*)0;
 T1_ = memset(a_p0, v_p1, ((size_t) (size_p2)));
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
 NIM_BOOL* result;
 result = (&nimInErrorMode__system_u4445);
 return result;
}
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
 nimSetMem__systemZmemory_u7(p_p0, ((int)0), size_p1);
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }BeforeRet_: ;
}
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
 {
  if (!(framePtr__system_u4048 == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s_p0).calldepth = ((NI16)0);
 }
 goto LA1_;
LA3_: ;
 {
  (*s_p0).calldepth = (NI16)((*framePtr__system_u4048).calldepth + ((NI16)1));
 }
LA1_: ;
 (*s_p0).prev = framePtr__system_u4048;
 framePtr__system_u4048 = s_p0;
 {
  if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
  callDepthLimitReached__system_u4661();
 }
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__system_u4048 = (*framePtr__system_u4048).prev;
}
N_LIB_PRIVATE N_NIMCALL(NimStringV2, bar__temp_u12)(NI x_p0) {
 NimStringV2 result;
 NI ttt`gensym0;
NIM_BOOL* nimErr_;
 nimfr_("bar", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
 ttt`gensym0 = x_p0;
 result = dollar___systemZdollars_u8(ttt`gensym0);
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }BeforeRet_: ;
 popFrame();
 return result;
}
N_LIB_PRIVATE N_NIMCALL(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ, foo)(void) {
 tyObject_r__k69bgTG9anxUFadPjWOwGmWQ result;
 NimStringV2 s;
NIM_BOOL* nimErr_;
 nimfr_("foo", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
 nimZeroMem((void*)(&result), sizeof(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ));
 s.len = 0; s.p = NIM_NIL;
 s = bar__temp_u12(((NI)123));
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 if (s.p && !(s.p->cap & NIM_STRLIT_FLAG)) {
deallocShared(s.p);
}
 }BeforeRet_: ;
 popFrame();
 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_;
 tyObject_r__k69bgTG9anxUFadPjWOwGmWQ T3_;
NIM_BOOL* nimErr_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
 colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
 T3_ = foo();
 if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
 colontmpD_ = dollar___temp_u38(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();
}
}

Stats

  • Started 2023-11-14T13:30:20
  • Finished 2023-11-14T13:30:21
  • Duration 1 minutes

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      nnkPostfix.newTree(
        newIdentNode("*"),
        newIdentNode("r")
      ),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        newEmptyNode()
      )
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("std"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newEmptyNode(),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("T"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          nnkPragmaExpr.newTree(
            newIdentNode("ttt"),
            nnkPragma.newTree(
              newIdentNode("used")
            )
          ),
          newEmptyNode(),
          newIdentNode("x")
        )
      ),
      nnkAsgn.newTree(
        newIdentNode("result"),
        nnkPrefix.newTree(
          newIdentNode("$"),
          newIdentNode("ttt")
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("bar"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newEmptyNode(),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("T"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        newIdentNode("std"),
        newIdentNode("x")
      )
    )
  ),
  nnkPragma.newTree(
    newIdentNode("push"),
    nnkExprColonExpr.newTree(
      newIdentNode("exportc"),
      newLit("$1")
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("r")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("s"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("bar"),
            newLit(123)
          )
        )
      )
    )
  ),
  nnkPragma.newTree(
    newIdentNode("pop")
  ),
  nnkCommand.newTree(
    newIdentNode("echo"),
    nnkCall.newTree(
      newIdentNode("foo")
    )
  )
)
stable 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints: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/@mtemp.nim.c: In function ‘bar__temp_u12’:
/home/runner/work/Nim/Nim/@mtemp.nim.c:110:15: error: stray ‘`’ in program
  110 |         NI ttt`gensym0;
      |               ^
/home/runner/work/Nim/Nim/@mtemp.nim.c:110:16: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gensym0’
  110 |         NI ttt`gensym0;
      |                ^~~~~~~
/home/runner/work/Nim/Nim/@mtemp.nim.c:110:16: error: ‘gensym0’ undeclared (first use in this function)
/home/runner/work/Nim/Nim/@mtemp.nim.c:110:16: note: each undeclared identifier is reported only once for each function it appears in
compilation terminated due to -fmax-errors=3.
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


assertions.nim(34)       raiseAssert
Error: unhandled exception: options.nim(664, 5) `false` errGenerated [AssertionDefect]

IR

Compiled filesize 0 bytes (0 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#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;
typedef struct tyObject_r__k69bgTG9anxUFadPjWOwGmWQ tyObject_r__k69bgTG9anxUFadPjWOwGmWQ;
struct NimStrPayload {
 NI cap;
 NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
 NI len;
 NimStrPayload* p;
};
struct tyObject_r__k69bgTG9anxUFadPjWOwGmWQ {
 char dummy;
};
typedef NimStringV2 tyArray__nHXaesL0DJZHyVS07ARPRA[1];
N_LIB_PRIVATE N_NIMCALL(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ, foo)(void);
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1);
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, bar__temp_u12)(NI x_p0);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, dollar___systemZdollars_u8)(NI x_p0);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4607)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, dollar___temp_u38)(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ x_p0);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringV2* args_p0, NI args_p0Len_0);
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 NIM_BOOL nimInErrorMode__system_u4389;
extern NIM_THREADVAR TFrame* framePtr__system_u4006;
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2) {
 void* T1_;
 T1_ = (void*)0;
 T1_ = memset(a_p0, v_p1, ((size_t) (size_p2)));
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
 NIM_BOOL* result;
 result = (NIM_BOOL*)0;
 result = (&nimInErrorMode__system_u4389);
 return result;
}
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
 nimSetMem__systemZmemory_u7(p_p0, ((int)0), size_p1);
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }BeforeRet_: ;
}
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
 {
  if (!(framePtr__system_u4006 == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s_p0).calldepth = ((NI16)0);
 }
 goto LA1_;
LA3_: ;
 {
  (*s_p0).calldepth = (NI16)((*framePtr__system_u4006).calldepth + ((NI16)1));
 }
LA1_: ;
 (*s_p0).prev = framePtr__system_u4006;
 framePtr__system_u4006 = s_p0;
 {
  if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
  callDepthLimitReached__system_u4607();
 }
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__system_u4006 = (*framePtr__system_u4006).prev;
}
N_LIB_PRIVATE N_NIMCALL(NimStringV2, bar__temp_u12)(NI x_p0) {
 NimStringV2 result;
 NI ttt`gensym0;
NIM_BOOL* nimErr_;
 nimfr_("bar", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
 result.len = 0; result.p = NIM_NIL;
 ttt`gensym0 = x_p0;
 result = dollar___systemZdollars_u8(ttt`gensym0);
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }BeforeRet_: ;
 popFrame();
 return result;
}
N_LIB_PRIVATE N_NIMCALL(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ, foo)(void) {
 tyObject_r__k69bgTG9anxUFadPjWOwGmWQ result;
 NimStringV2 s;
NIM_BOOL* nimErr_;
 nimfr_("foo", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
 nimZeroMem((void*)(&result), sizeof(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ));
 s.len = 0; s.p = NIM_NIL;
 s = bar__temp_u12(((NI)123));
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 if (s.p && !(s.p->cap & NIM_STRLIT_FLAG)) {
deallocShared(s.p);
}
 }BeforeRet_: ;
 popFrame();
 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_;
 tyObject_r__k69bgTG9anxUFadPjWOwGmWQ T3_;
NIM_BOOL* nimErr_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
 colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
 T3_ = foo();
 if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
 colontmpD_ = dollar___temp_u38(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();
}
}

Stats

  • Started 2023-11-14T13:30:22
  • Finished 2023-11-14T13:30:23
  • Duration

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      nnkPostfix.newTree(
        newIdentNode("*"),
        newIdentNode("r")
      ),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        newEmptyNode()
      )
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("std"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newEmptyNode(),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("T"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          nnkPragmaExpr.newTree(
            newIdentNode("ttt"),
            nnkPragma.newTree(
              newIdentNode("used")
            )
          ),
          newEmptyNode(),
          newIdentNode("x")
        )
      ),
      nnkAsgn.newTree(
        newIdentNode("result"),
        nnkPrefix.newTree(
          newIdentNode("$"),
          newIdentNode("ttt")
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("bar"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newEmptyNode(),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("T"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        newIdentNode("std"),
        newIdentNode("x")
      )
    )
  ),
  nnkPragma.newTree(
    newIdentNode("push"),
    nnkExprColonExpr.newTree(
      newIdentNode("exportc"),
      newLit("$1")
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("r")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("s"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("bar"),
            newLit(123)
          )
        )
      )
    )
  ),
  nnkPragma.newTree(
    newIdentNode("pop")
  ),
  nnkCommand.newTree(
    newIdentNode("echo"),
    nnkCall.newTree(
      newIdentNode("foo")
    )
  )
)
2.0.0 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints: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/@mtemp.nim.c: In function ‘bar__temp_u12’:
/home/runner/work/Nim/Nim/@mtemp.nim.c:110:15: error: stray ‘`’ in program
  110 |         NI ttt`gensym0;
      |               ^
/home/runner/work/Nim/Nim/@mtemp.nim.c:110:16: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gensym0’
  110 |         NI ttt`gensym0;
      |                ^~~~~~~
/home/runner/work/Nim/Nim/@mtemp.nim.c:110:16: error: ‘gensym0’ undeclared (first use in this function)
/home/runner/work/Nim/Nim/@mtemp.nim.c:110:16: note: each undeclared identifier is reported only once for each function it appears in
compilation terminated due to -fmax-errors=3.
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


assertions.nim(34)       raiseAssert
Error: unhandled exception: options.nim(664, 5) `false` errGenerated [AssertionDefect]

IR

Compiled filesize 0 bytes (0 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#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;
typedef struct tyObject_r__k69bgTG9anxUFadPjWOwGmWQ tyObject_r__k69bgTG9anxUFadPjWOwGmWQ;
struct NimStrPayload {
 NI cap;
 NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
 NI len;
 NimStrPayload* p;
};
struct tyObject_r__k69bgTG9anxUFadPjWOwGmWQ {
 char dummy;
};
typedef NimStringV2 tyArray__nHXaesL0DJZHyVS07ARPRA[1];
N_LIB_PRIVATE N_NIMCALL(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ, foo)(void);
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1);
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, bar__temp_u12)(NI x_p0);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, dollar___systemZdollars_u8)(NI x_p0);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4607)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, dollar___temp_u38)(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ x_p0);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringV2* args_p0, NI args_p0Len_0);
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 NIM_BOOL nimInErrorMode__system_u4389;
extern NIM_THREADVAR TFrame* framePtr__system_u4006;
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2) {
 void* T1_;
 T1_ = (void*)0;
 T1_ = memset(a_p0, v_p1, ((size_t) (size_p2)));
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
 NIM_BOOL* result;
 result = (NIM_BOOL*)0;
 result = (&nimInErrorMode__system_u4389);
 return result;
}
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
 nimSetMem__systemZmemory_u7(p_p0, ((int)0), size_p1);
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }BeforeRet_: ;
}
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
 {
  if (!(framePtr__system_u4006 == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s_p0).calldepth = ((NI16)0);
 }
 goto LA1_;
LA3_: ;
 {
  (*s_p0).calldepth = (NI16)((*framePtr__system_u4006).calldepth + ((NI16)1));
 }
LA1_: ;
 (*s_p0).prev = framePtr__system_u4006;
 framePtr__system_u4006 = s_p0;
 {
  if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
  callDepthLimitReached__system_u4607();
 }
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__system_u4006 = (*framePtr__system_u4006).prev;
}
N_LIB_PRIVATE N_NIMCALL(NimStringV2, bar__temp_u12)(NI x_p0) {
 NimStringV2 result;
 NI ttt`gensym0;
NIM_BOOL* nimErr_;
 nimfr_("bar", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
 result.len = 0; result.p = NIM_NIL;
 ttt`gensym0 = x_p0;
 result = dollar___systemZdollars_u8(ttt`gensym0);
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }BeforeRet_: ;
 popFrame();
 return result;
}
N_LIB_PRIVATE N_NIMCALL(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ, foo)(void) {
 tyObject_r__k69bgTG9anxUFadPjWOwGmWQ result;
 NimStringV2 s;
NIM_BOOL* nimErr_;
 nimfr_("foo", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
 nimZeroMem((void*)(&result), sizeof(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ));
 s.len = 0; s.p = NIM_NIL;
 s = bar__temp_u12(((NI)123));
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 if (s.p && !(s.p->cap & NIM_STRLIT_FLAG)) {
deallocShared(s.p);
}
 }BeforeRet_: ;
 popFrame();
 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_;
 tyObject_r__k69bgTG9anxUFadPjWOwGmWQ T3_;
NIM_BOOL* nimErr_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
 colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
 T3_ = foo();
 if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
 colontmpD_ = dollar___temp_u38(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();
}
}

Stats

  • Started 2023-11-14T13:30:23
  • Finished 2023-11-14T13:30:24
  • Duration

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      nnkPostfix.newTree(
        newIdentNode("*"),
        newIdentNode("r")
      ),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        newEmptyNode()
      )
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("std"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newEmptyNode(),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("T"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          nnkPragmaExpr.newTree(
            newIdentNode("ttt"),
            nnkPragma.newTree(
              newIdentNode("used")
            )
          ),
          newEmptyNode(),
          newIdentNode("x")
        )
      ),
      nnkAsgn.newTree(
        newIdentNode("result"),
        nnkPrefix.newTree(
          newIdentNode("$"),
          newIdentNode("ttt")
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("bar"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newEmptyNode(),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("T"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        newIdentNode("std"),
        newIdentNode("x")
      )
    )
  ),
  nnkPragma.newTree(
    newIdentNode("push"),
    nnkExprColonExpr.newTree(
      newIdentNode("exportc"),
      newLit("$1")
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("r")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("s"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("bar"),
            newLit(123)
          )
        )
      )
    )
  ),
  nnkPragma.newTree(
    newIdentNode("pop")
  ),
  nnkCommand.newTree(
    newIdentNode("echo"),
    nnkCall.newTree(
      newIdentNode("foo")
    )
  )
)
1.6.14 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints: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/@mtemp.nim.c: In function ‘bar__temp_12’:
/home/runner/work/Nim/Nim/@mtemp.nim.c:100:15: error: stray ‘`’ in program
  100 |         NI ttt`gensym0;
      |               ^
/home/runner/work/Nim/Nim/@mtemp.nim.c:100:16: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gensym0’
  100 |         NI ttt`gensym0;
      |                ^~~~~~~
/home/runner/work/Nim/Nim/@mtemp.nim.c:100:16: error: ‘gensym0’ undeclared (first use in this function)
/home/runner/work/Nim/Nim/@mtemp.nim.c:100:16: note: each undeclared identifier is reported only once for each function it appears in
compilation terminated due to -fmax-errors=3.
Error: execution of an external compiler program 'gcc -c  -w -fmax-errors=3   -I/home/runner/.choosenim/toolchains/nim-1.6.14/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


fatal.nim(54)            sysFatal
Error: unhandled exception: options.nim(645, 14) `false` errGenerated [AssertionDefect]

IR

Compiled filesize 0 bytes (0 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#  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, file) \
 FR_.line = n; FR_.filename = file;
typedef struct tyObject_r__k69bgTG9anxUFadPjWOwGmWQ tyObject_r__k69bgTG9anxUFadPjWOwGmWQ;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
struct tyObject_r__k69bgTG9anxUFadPjWOwGmWQ {
char dummy;
};
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef NimStringDesc* tyArray__nHXaesL0DJZHyVS07ARPRA[1];
N_LIB_PRIVATE N_NIMCALL(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ, foo)(void);
static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem__systemZmemory_7)(void* a, int v, NI size);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, bar__temp_12)(NI x);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, dollar___systemZdollars_3)(NI x);
static N_INLINE(void, nimFrame)(TFrame* s);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_2997)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, dollar___temp_33)(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ x);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringDesc** args, NI argsLen_0);
static N_INLINE(void, initStackBottomWith)(void* locals);
N_LIB_PRIVATE N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_DatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
extern TFrame* framePtr__system_2564;
extern TFrame* framePtr__system_2564;
extern TFrame* framePtr__system_2564;
extern TFrame* framePtr__system_2564;
extern TFrame* framePtr__system_2564;
extern TFrame* framePtr__system_2564;
static N_INLINE(void, nimSetMem__systemZmemory_7)(void* a, int v, NI size) {
 void* T1_;
 T1_ = (void*)0;
 T1_ = memset(a, v, ((size_t) (size)));
}
static N_INLINE(void, nimZeroMem)(void* p, NI size) {
 nimSetMem__systemZmemory_7(p, ((int) 0), size);
}
static N_INLINE(void, nimFrame)(TFrame* s) {
 {
  if (!(framePtr__system_2564 == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s).calldepth = ((NI16) 0);
 }
 goto LA1_;
 LA3_: ;
 {
  (*s).calldepth = (NI16)((*framePtr__system_2564).calldepth + ((NI16) 1));
 }
 LA1_: ;
 (*s).prev = framePtr__system_2564;
 framePtr__system_2564 = s;
 {
  if (!((*s).calldepth == ((NI16) 2000))) goto LA8_;
  callDepthLimitReached__system_2997();
 }
 LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__system_2564 = (*framePtr__system_2564).prev;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, bar__temp_12)(NI x) {
 NimStringDesc* result;
 NI ttt`gensym0;
 nimfr_("bar", "/home/runner/work/Nim/Nim/temp.nim");
 result = NIM_NIL;
 ttt`gensym0 = x;
 result = dollar___systemZdollars_3(ttt`gensym0);
 popFrame();
 return result;
}
N_LIB_PRIVATE N_NIMCALL(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ, foo)(void) {
 tyObject_r__k69bgTG9anxUFadPjWOwGmWQ result;
 NimStringDesc* s;
 nimfr_("foo", "/home/runner/work/Nim/Nim/temp.nim");
 nimZeroMem((void*)(&result), sizeof(tyObject_r__k69bgTG9anxUFadPjWOwGmWQ));
 s = bar__temp_12(((NI) 123));
 popFrame();
 return result;
}
static N_INLINE(void, initStackBottomWith)(void* locals) {
 nimGC_setStackBottom(locals);
}
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) {
 void (*volatile inner)(void);
 inner = PreMainInner;
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_DatInit000();
 initStackBottomWith((void *)&inner);
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_Init000();
 (*inner)();
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
 NimMainModule();
}
N_CDECL(void, NimMain)(void) {
 void (*volatile inner)(void);
 PreMain();
 inner = NimMainInner;
 initStackBottomWith((void *)&inner);
 (*inner)();
}
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) {
{
 tyArray__nHXaesL0DJZHyVS07ARPRA T1_;
 tyObject_r__k69bgTG9anxUFadPjWOwGmWQ T2_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
 nimZeroMem((void*)T1_, sizeof(tyArray__nHXaesL0DJZHyVS07ARPRA));
 T2_ = foo();
 T1_[0] = dollar___temp_33(T2_);
 echoBinSafe(T1_, 1);
 popFrame();
}
}

Stats

  • Started 2023-11-14T13:30:28
  • Finished 2023-11-14T13:30:29
  • Duration

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      nnkPostfix.newTree(
        newIdentNode("*"),
        newIdentNode("r")
      ),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        newEmptyNode()
      )
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("std"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newEmptyNode(),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("T"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          nnkPragmaExpr.newTree(
            newIdentNode("ttt"),
            nnkPragma.newTree(
              newIdentNode("used")
            )
          ),
          newEmptyNode(),
          newIdentNode("x")
        )
      ),
      nnkAsgn.newTree(
        newIdentNode("result"),
        nnkPrefix.newTree(
          newIdentNode("$"),
          newIdentNode("ttt")
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("bar"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newEmptyNode(),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("T"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        newIdentNode("std"),
        newIdentNode("x")
      )
    )
  ),
  nnkPragma.newTree(
    newIdentNode("push"),
    nnkExprColonExpr.newTree(
      newIdentNode("exportc"),
      newLit("$1")
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("r")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("s"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("bar"),
            newLit(123)
          )
        )
      )
    )
  ),
  nnkPragma.newTree(
    newIdentNode("pop")
  ),
  nnkCommand.newTree(
    newIdentNode("echo"),
    nnkCall.newTree(
      newIdentNode("foo")
    )
  )
)
1.4.8 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints: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/@mtemp.nim.c: In function ‘bar__Y1Dhtj9aWamkIg1qnn1gf3g’:
/home/runner/work/Nim/Nim/@mtemp.nim.c:116:15: error: stray ‘`’ in program
  116 |         NI ttt`gensym0;
      |               ^
/home/runner/work/Nim/Nim/@mtemp.nim.c:116:16: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gensym0’
  116 |         NI ttt`gensym0;
      |                ^~~~~~~
/home/runner/work/Nim/Nim/@mtemp.nim.c:116:16: error: ‘gensym0’ undeclared (first use in this function)
/home/runner/work/Nim/Nim/@mtemp.nim.c:116:16: note: each undeclared identifier is reported only once for each function it appears in
compilation terminated due to -fmax-errors=3.
Error: execution of an external compiler program 'gcc -c  -w -fmax-errors=3   -I/home/runner/.choosenim/toolchains/nim-1.4.8/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

IR

Compiled filesize 0 bytes (0 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#  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, file) \
 FR_.line = n; FR_.filename = file;
typedef struct tyObject_r__K5x2PVxkVglpEfIjXIUwNg tyObject_r__K5x2PVxkVglpEfIjXIUwNg;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
struct tyObject_r__K5x2PVxkVglpEfIjXIUwNg {
char dummy;
};
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef NimStringDesc* tyArray__nHXaesL0DJZHyVS07ARPRA[1];
N_LIB_PRIVATE N_NIMCALL(tyObject_r__K5x2PVxkVglpEfIjXIUwNg, foo)(void);
static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, bar__Y1Dhtj9aWamkIg1qnn1gf3g)(NI x);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nimIntToStr)(NI x);
static N_INLINE(void, nimFrame)(TFrame* s);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__mMRdr4sgmnykA9aWeM9aDZlw)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, dollar___amsefZ1s2PW9aEvuypph2eQ)(tyObject_r__K5x2PVxkVglpEfIjXIUwNg x);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringDesc** args, NI argsLen_0);
static N_INLINE(void, initStackBottomWith)(void* locals);
N_LIB_PRIVATE N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom);
N_LIB_PRIVATE N_NIMCALL(void, systemDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size) {
 void* T1_;
 T1_ = (void*)0;
 T1_ = memset(a, v, ((size_t) (size)));
}
static N_INLINE(void, nimZeroMem)(void* p, NI size) {
 nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory(p, ((int) 0), size);
}
static N_INLINE(void, nimFrame)(TFrame* s) {
 {
  if (!(framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s).calldepth = ((NI16) 0);
 }
 goto LA1_;
 LA3_: ;
 {
  (*s).calldepth = (NI16)((*framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw).calldepth + ((NI16) 1));
 }
 LA1_: ;
 (*s).prev = framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
 framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw = s;
 {
  if (!((*s).calldepth == ((NI16) 2000))) goto LA8_;
  callDepthLimitReached__mMRdr4sgmnykA9aWeM9aDZlw();
 }
 LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw = (*framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw).prev;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, bar__Y1Dhtj9aWamkIg1qnn1gf3g)(NI x) {
 NimStringDesc* result;
 NI ttt`gensym0;
 nimfr_("bar", "/home/runner/work/Nim/Nim/temp.nim");
 result = (NimStringDesc*)0;
 ttt`gensym0 = x;
 result = nimIntToStr(ttt`gensym0);
 popFrame();
 return result;
}
N_LIB_PRIVATE N_NIMCALL(tyObject_r__K5x2PVxkVglpEfIjXIUwNg, foo)(void) {
 tyObject_r__K5x2PVxkVglpEfIjXIUwNg result;
 NimStringDesc* s;
 nimfr_("foo", "/home/runner/work/Nim/Nim/temp.nim");
 nimZeroMem((void*)(&result), sizeof(tyObject_r__K5x2PVxkVglpEfIjXIUwNg));
 s = bar__Y1Dhtj9aWamkIg1qnn1gf3g(((NI) 123));
 popFrame();
 return result;
}
static N_INLINE(void, initStackBottomWith)(void* locals) {
 nimGC_setStackBottom(locals);
}
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) {
 void (*volatile inner)(void);
 inner = PreMainInner;
 systemDatInit000();
 initStackBottomWith((void *)&inner);
 systemInit000();
 (*inner)();
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
 NimMainModule();
}
N_CDECL(void, NimMain)(void) {
 void (*volatile inner)(void);
 PreMain();
 inner = NimMainInner;
 initStackBottomWith((void *)&inner);
 (*inner)();
}
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) {
{
 tyArray__nHXaesL0DJZHyVS07ARPRA T1_;
 tyObject_r__K5x2PVxkVglpEfIjXIUwNg T2_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
 nimZeroMem((void*)T1_, sizeof(tyArray__nHXaesL0DJZHyVS07ARPRA));
 T2_ = foo();
 T1_[0] = dollar___amsefZ1s2PW9aEvuypph2eQ(T2_);
 echoBinSafe(T1_, 1);
 popFrame();
}
}

Stats

  • Started 2023-11-14T13:30:33
  • Finished 2023-11-14T13:30:34
  • Duration

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      nnkPostfix.newTree(
        newIdentNode("*"),
        newIdentNode("r")
      ),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        newEmptyNode()
      )
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("std"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newEmptyNode(),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("T"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          nnkPragmaExpr.newTree(
            newIdentNode("ttt"),
            nnkPragma.newTree(
              newIdentNode("used")
            )
          ),
          newEmptyNode(),
          newIdentNode("x")
        )
      ),
      nnkAsgn.newTree(
        newIdentNode("result"),
        nnkPrefix.newTree(
          newIdentNode("$"),
          newIdentNode("ttt")
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("bar"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newEmptyNode(),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("T"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        newIdentNode("std"),
        newIdentNode("x")
      )
    )
  ),
  nnkPragma.newTree(
    newIdentNode("push"),
    nnkExprColonExpr.newTree(
      newIdentNode("exportc"),
      newLit("$1")
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("r")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("s"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("bar"),
            newLit(123)
          )
        )
      )
    )
  ),
  nnkPragma.newTree(
    newIdentNode("pop")
  ),
  nnkCommand.newTree(
    newIdentNode("echo"),
    nnkCall.newTree(
      newIdentNode("foo")
    )
  )
)
1.2.18 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints: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/@mtemp.nim.c: In function ‘bar__Y1Dhtj9aWamkIg1qnn1gf3g’:
/home/runner/work/Nim/Nim/@mtemp.nim.c:102:15: error: stray ‘`’ in program
  102 |         NI ttt`gensym3387029;
      |               ^
/home/runner/work/Nim/Nim/@mtemp.nim.c:102:16: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gensym3387029’
  102 |         NI ttt`gensym3387029;
      |                ^~~~~~~~~~~~~
/home/runner/work/Nim/Nim/@mtemp.nim.c:102:16: error: ‘gensym3387029’ undeclared (first use in this function)
/home/runner/work/Nim/Nim/@mtemp.nim.c:102:16: note: each undeclared identifier is reported only once for each function it appears in
/home/runner/work/Nim/Nim/@mtemp.nim.c:105:12: error: stray ‘`’ in program
  105 |         ttt`gensym3387029 = x;
      |            ^
/home/runner/work/Nim/Nim/@mtemp.nim.c:105:9: error: unknown type name ‘ttt’
  105 |         ttt`gensym3387029 = x;
      |         ^~~
/home/runner/work/Nim/Nim/@mtemp.nim.c:106:33: error: stray ‘`’ in program
  106 |         result = nimIntToStr(ttt`gensym3387029);
      |                                 ^
/home/runner/work/Nim/Nim/@mtemp.nim.c:106:30: error: ‘ttt’ undeclared (first use in this function)
  106 |         result = nimIntToStr(ttt`gensym3387029);
      |                              ^~~
/home/runner/work/Nim/Nim/@mtemp.nim.c:106:33: error: expected ‘)’ before ‘gensym3387029’
  106 |         result = nimIntToStr(ttt`gensym3387029);
      |                             ~   ^~~~~~~~~~~~~~
      |                                 )
Error: execution of an external compiler program 'gcc -c  -w   -I/home/runner/.choosenim/toolchains/nim-1.2.18/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

IR

Compiled filesize 0 bytes (0 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#  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, file) \
 FR_.line = n; FR_.filename = file;
typedef struct tyObject_r__K5x2PVxkVglpEfIjXIUwNg tyObject_r__K5x2PVxkVglpEfIjXIUwNg;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
struct tyObject_r__K5x2PVxkVglpEfIjXIUwNg {
char dummy;
};
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef NimStringDesc* tyArray__nHXaesL0DJZHyVS07ARPRA[1];
N_LIB_PRIVATE N_NIMCALL(tyObject_r__K5x2PVxkVglpEfIjXIUwNg, foo)(void);
static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, bar__Y1Dhtj9aWamkIg1qnn1gf3g)(NI x);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nimIntToStr)(NI x);
static N_INLINE(void, nimFrame)(TFrame* s);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__mMRdr4sgmnykA9aWeM9aDZlw)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, dollar___amsefZ1s2PW9aEvuypph2eQ)(tyObject_r__K5x2PVxkVglpEfIjXIUwNg x);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringDesc** args, NI argsLen_0);
static N_INLINE(void, initStackBottomWith)(void* locals);
N_LIB_PRIVATE N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom);
N_LIB_PRIVATE N_NIMCALL(void, systemDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size) {
 void* T1_;
 T1_ = (void*)0;
 T1_ = memset(a, v, ((size_t) (size)));
}
static N_INLINE(void, nimZeroMem)(void* p, NI size) {
 nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory(p, ((int) 0), size);
}
static N_INLINE(void, nimFrame)(TFrame* s) {
 {
  if (!(framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw == NIM_NIL)) goto LA3_;
  (*s).calldepth = ((NI16) 0);
 }
 goto LA1_;
 LA3_: ;
 {
  (*s).calldepth = (NI16)((*framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw).calldepth + ((NI16) 1));
 }
 LA1_: ;
 (*s).prev = framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
 framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw = s;
 {
  if (!((*s).calldepth == ((NI16) (((NI) 2000))))) goto LA8_;
  callDepthLimitReached__mMRdr4sgmnykA9aWeM9aDZlw();
 }
 LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw = (*framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw).prev;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, bar__Y1Dhtj9aWamkIg1qnn1gf3g)(NI x) {
 NimStringDesc* result;
 NI ttt`gensym3387029;
 nimfr_("bar", "/home/runner/work/Nim/Nim/temp.nim");
 result = NIM_NIL;
 ttt`gensym3387029 = x;
 result = nimIntToStr(ttt`gensym3387029);
 popFrame();
 return result;
}
N_LIB_PRIVATE N_NIMCALL(tyObject_r__K5x2PVxkVglpEfIjXIUwNg, foo)(void) {
 tyObject_r__K5x2PVxkVglpEfIjXIUwNg result;
 NimStringDesc* s;
 nimfr_("foo", "/home/runner/work/Nim/Nim/temp.nim");
 nimZeroMem((void*)(&result), sizeof(tyObject_r__K5x2PVxkVglpEfIjXIUwNg));
 s = bar__Y1Dhtj9aWamkIg1qnn1gf3g(((NI) 123));
 popFrame();
 return result;
}
static N_INLINE(void, initStackBottomWith)(void* locals) {
 nimGC_setStackBottom(locals);
}
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) {
 void (*volatile inner)(void);
 inner = PreMainInner;
 systemDatInit000();
 initStackBottomWith((void *)&inner);
 systemInit000();
 (*inner)();
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
 NimMainModule();
}
N_CDECL(void, NimMain)(void) {
 void (*volatile inner)(void);
 PreMain();
 inner = NimMainInner;
 initStackBottomWith((void *)&inner);
 (*inner)();
}
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) {
{
 tyArray__nHXaesL0DJZHyVS07ARPRA T1_;
 tyObject_r__K5x2PVxkVglpEfIjXIUwNg T2_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
 nimZeroMem((void*)T1_, sizeof(tyArray__nHXaesL0DJZHyVS07ARPRA));
 T2_ = foo();
 T1_[0] = dollar___amsefZ1s2PW9aEvuypph2eQ(T2_);
 echoBinSafe(T1_, 1);
 popFrame();
}
}

Stats

  • Started 2023-11-14T13:30:37
  • Finished 2023-11-14T13:30:38
  • Duration

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      nnkPostfix.newTree(
        newIdentNode("*"),
        newIdentNode("r")
      ),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        newEmptyNode()
      )
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("std"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newEmptyNode(),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("T"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          nnkPragmaExpr.newTree(
            newIdentNode("ttt"),
            nnkPragma.newTree(
              newIdentNode("used")
            )
          ),
          newEmptyNode(),
          newIdentNode("x")
        )
      ),
      nnkAsgn.newTree(
        newIdentNode("result"),
        nnkPrefix.newTree(
          newIdentNode("$"),
          newIdentNode("ttt")
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("bar"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newEmptyNode(),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("T"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        newIdentNode("std"),
        newIdentNode("x")
      )
    )
  ),
  nnkPragma.newTree(
    newIdentNode("push"),
    nnkExprColonExpr.newTree(
      newIdentNode("exportc"),
      newLit("$1")
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("r")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("s"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("bar"),
            newLit(123)
          )
        )
      )
    )
  ),
  nnkPragma.newTree(
    newIdentNode("pop")
  ),
  nnkCommand.newTree(
    newIdentNode("echo"),
    nnkCall.newTree(
      newIdentNode("foo")
    )
  )
)
1.0.10 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
Error: execution of an external compiler program 'gcc -c  -w  -I/home/runner/.choosenim/toolchains/nim-1.0.10/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

/home/runner/work/Nim/Nim/@mtemp.nim.c: In function ‘bar__Y1Dhtj9aWamkIg1qnn1gf3g’:
/home/runner/work/Nim/Nim/@mtemp.nim.c:100:15: error: stray ‘`’ in program
  100 |         NI ttt`gensym133029;
      |               ^
/home/runner/work/Nim/Nim/@mtemp.nim.c:100:16: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gensym133029’
  100 |         NI ttt`gensym133029;
      |                ^~~~~~~~~~~~
/home/runner/work/Nim/Nim/@mtemp.nim.c:100:16: error: ‘gensym133029’ undeclared (first use in this function)
/home/runner/work/Nim/Nim/@mtemp.nim.c:100:16: note: each undeclared identifier is reported only once for each function it appears in
/home/runner/work/Nim/Nim/@mtemp.nim.c:103:12: error: stray ‘`’ in program
  103 |         ttt`gensym133029 = x;
      |            ^
/home/runner/work/Nim/Nim/@mtemp.nim.c:103:9: error: unknown type name ‘ttt’
  103 |         ttt`gensym133029 = x;
      |         ^~~
/home/runner/work/Nim/Nim/@mtemp.nim.c:104:33: error: stray ‘`’ in program
  104 |         result = nimIntToStr(ttt`gensym133029);
      |                                 ^
/home/runner/work/Nim/Nim/@mtemp.nim.c:104:30: error: ‘ttt’ undeclared (first use in this function)
  104 |         result = nimIntToStr(ttt`gensym133029);
      |                              ^~~
/home/runner/work/Nim/Nim/@mtemp.nim.c:104:33: error: expected ‘)’ before ‘gensym133029’
  104 |         result = nimIntToStr(ttt`gensym133029);
      |                             ~   ^~~~~~~~~~~~~
      |                                 )

IR

Compiled filesize 0 bytes (0 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#  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, file) \
 FR_.line = n; FR_.filename = file;
typedef struct tyObject_r__K5x2PVxkVglpEfIjXIUwNg tyObject_r__K5x2PVxkVglpEfIjXIUwNg;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
struct tyObject_r__K5x2PVxkVglpEfIjXIUwNg {
char dummy;
};
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef NimStringDesc* tyArray__nHXaesL0DJZHyVS07ARPRA[1];
N_NIMCALL(tyObject_r__K5x2PVxkVglpEfIjXIUwNg, foo)(void);
static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, bar__Y1Dhtj9aWamkIg1qnn1gf3g)(NI x);
N_NIMCALL(NimStringDesc*, nimIntToStr)(NI x);
static N_INLINE(void, nimFrame)(TFrame* s);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__mMRdr4sgmnykA9aWeM9aDZlw)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, dollar___amsefZ1s2PW9aEvuypph2eQ)(tyObject_r__K5x2PVxkVglpEfIjXIUwNg x);
N_NIMCALL(void, echoBinSafe)(NimStringDesc** args, NI argsLen_0);
static N_INLINE(void, initStackBottomWith)(void* locals);
N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom);
N_LIB_PRIVATE N_NIMCALL(void, systemDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size) {	void* T1_;
 T1_ = (void*)0;
 T1_ = memset(a, v, ((size_t) (size)));
}
static N_INLINE(void, nimZeroMem)(void* p, NI size) {	nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory(p, ((int) 0), size);
}
static N_INLINE(void, nimFrame)(TFrame* s) {	NI T1_;
 T1_ = (NI)0;
 {
  if (!(framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw == NIM_NIL)) goto LA4_;
  T1_ = ((NI) 0);
 }
 goto LA2_;
 LA4_: ;
 {
  T1_ = ((NI) ((NI16)((*framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw).calldepth + ((NI16) 1))));
 }
 LA2_: ;
 (*s).calldepth = ((NI16) (T1_));
 (*s).prev = framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
 framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw = s;
 {
  if (!((*s).calldepth == ((NI16) (((NI) 2000))))) goto LA9_;
  callDepthLimitReached__mMRdr4sgmnykA9aWeM9aDZlw();
 }
 LA9_: ;
}
static N_INLINE(void, popFrame)(void) {	framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw = (*framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw).prev;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, bar__Y1Dhtj9aWamkIg1qnn1gf3g)(NI x) {	NimStringDesc* result;
 NI ttt`gensym133029;
 nimfr_("bar", "/home/runner/work/Nim/Nim/temp.nim");
 result = (NimStringDesc*)0;
 ttt`gensym133029 = x;
 result = nimIntToStr(ttt`gensym133029);
 popFrame();
 return result;
}
N_NIMCALL(tyObject_r__K5x2PVxkVglpEfIjXIUwNg, foo)(void) {	tyObject_r__K5x2PVxkVglpEfIjXIUwNg result;
 NimStringDesc* s;
 nimfr_("foo", "/home/runner/work/Nim/Nim/temp.nim");
 nimZeroMem((void*)(&result), sizeof(tyObject_r__K5x2PVxkVglpEfIjXIUwNg));
 s = bar__Y1Dhtj9aWamkIg1qnn1gf3g(((NI) 123));
 popFrame();
 return result;
}
static N_INLINE(void, initStackBottomWith)(void* locals) {	nimGC_setStackBottom(locals);
}
void PreMainInner(void) {
}
int cmdCount;
char** cmdLine;
char** gEnv;
void PreMain(void) {
 void (*volatile inner)(void);
 inner = PreMainInner;
 systemDatInit000();
 initStackBottomWith((void *)&inner);
 systemInit000();
 (*inner)();
}
N_CDECL(void, NimMainInner)(void) {
 NimMainModule();
}
N_CDECL(void, NimMain)(void) {
 void (*volatile inner)(void);
 PreMain();
 inner = NimMainInner;
 initStackBottomWith((void *)&inner);
 (*inner)();
}
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) {
{
 tyArray__nHXaesL0DJZHyVS07ARPRA T1_;
 tyObject_r__K5x2PVxkVglpEfIjXIUwNg T2_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
 nimZeroMem((void*)T1_, sizeof(tyArray__nHXaesL0DJZHyVS07ARPRA));
 T2_ = foo();
 T1_[0] = dollar___amsefZ1s2PW9aEvuypph2eQ(T2_);
 echoBinSafe(T1_, 1);
 popFrame();
}
}

Stats

  • Started 2023-11-14T13:30:40
  • Finished 2023-11-14T13:30:40
  • Duration

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      nnkPostfix.newTree(
        newIdentNode("*"),
        newIdentNode("r")
      ),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        newEmptyNode()
      )
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("std"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newEmptyNode(),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("T"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          nnkPragmaExpr.newTree(
            newIdentNode("ttt"),
            nnkPragma.newTree(
              newIdentNode("used")
            )
          ),
          newEmptyNode(),
          newIdentNode("x")
        )
      ),
      nnkAsgn.newTree(
        newIdentNode("result"),
        nnkPrefix.newTree(
          newIdentNode("$"),
          newIdentNode("ttt")
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("bar"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newEmptyNode(),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("T"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        newIdentNode("std"),
        newIdentNode("x")
      )
    )
  ),
  nnkPragma.newTree(
    newIdentNode("push"),
    nnkExprColonExpr.newTree(
      newIdentNode("exportc"),
      newLit("$1")
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("r")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("s"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("bar"),
            newLit(123)
          )
        )
      )
    )
  ),
  nnkPragma.newTree(
    newIdentNode("pop")
  ),
  nnkCommand.newTree(
    newIdentNode("echo"),
    nnkCall.newTree(
      newIdentNode("foo")
    )
  )
)
Stats
  • GCC 11.4.0
  • Clang 14.0.0
  • NodeJS 18.2
  • Created 2023-11-14T13:29:41Z
  • Comments 5
  • Commands nim c --run -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints: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 24 minutes bisecting 7 commits at 0 commits per second

@ringabout
Copy link
Member

ringabout commented Nov 14, 2023

Indeed, it's an old issue tracing back to 1.0.10. The push pragmas is leaking into the scope of the generics instantiations. Here is the reduced case

type r* = object


proc bar[T](x: T): string =
  let today {.used.} = 12 # an existing pragma ({.deprecated.} for another example) is needed for whatever the reason might be
  block:
    let today = 623.5
    echo today

{.push exportc: "$1".}
proc foo(): r =
  let s = bar(123)
{.pop.}

echo foo()

@ringabout
Copy link
Member

ringabout commented Nov 14, 2023

It seems that in the function instantiateBody for generics, it should somehow unload/ignore the current OptionEntry.

ringabout added a commit that referenced this issue Nov 15, 2023
Araq pushed a commit that referenced this issue Nov 19, 2023
#22941)

…tes invalid C identifiers

fixes #22913
fixes #12985 differently


`{.push.} now does not apply to generic instantiations`
narimiran pushed a commit that referenced this issue Apr 18, 2024
#22941)

…tes invalid C identifiers

fixes #22913
fixes #12985 differently

`{.push.} now does not apply to generic instantiations`

(cherry picked from commit 5dafcf4)
narimiran added a commit that referenced this issue Apr 19, 2024
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