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

Compiler segfaults when passing static parameter to non static macro parameter #22909

Closed
ire4ever1190 opened this issue Nov 4, 2023 · 13 comments · Fixed by #23271
Closed

Compiler segfaults when passing static parameter to non static macro parameter #22909

ire4ever1190 opened this issue Nov 4, 2023 · 13 comments · Fixed by #23271

Comments

@ire4ever1190
Copy link
Contributor

Description

This code breaks using devel compiler

!nim c

import std/macros

macro foo(a: openArray[string] = []): string =
  echo a # Segfault doesn't happen if this is removed
  newLit ""

proc bar(a: static[openArray[string]] = []) =
  const tmp = foo(a)

assert compiles(bar())

GDB shows it segfaulting in ORC

0x00005555557a4b6a in nimDecRefIsLastDyn (p_p0=p_p0@entry=0x5555556e33b9 <dealloc+9>) at /home/user/.choosenim/toolchains/nim-#devel/lib/system/orc.nim:495
495           dec cell.rc, rcIncrement
(gdb) where
#0  0x00005555557a4b6a in nimDecRefIsLastDyn (p_p0=p_p0@entry=0x5555556e33b9 <dealloc+9>) at /home/user/.choosenim/toolchains/nim-#devel/lib/system/orc.nim:495
#1  0x00005555557a79bf in eqdestroy___ast_u3777 (dest_p0=0x5555556e33b9 <dealloc+9>) at /home/user/Documents/projects/Nim/compiler/ast.nim:1233
#2  0x0000555555c7b7d2 in semConstExpr__sem_u668 (c_p0=c_p0@entry=0x7ffff5ef8060, n_p1=0x7ffff2249360, expectedType_p2=expectedType_p2@entry=0x0) at /home/user/Documents/projects/Nim/compiler/ast.nim:1233

Nim Version

Nim Compiler Version 2.1.1 [Linux: amd64]
Compiled at 2023-10-31
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: f61311f
active boot switches: -d:release

Current Output

Segfaults

Expected Output

Doesn't segfault

Possible Solution

No response

Additional Information

Bisected locally and found that #22032 is the cause

@ringabout
Copy link
Member

!nim c

import std/macros

macro foo(a: openArray[string] = []): string =
  echo a # Segfault doesn't happen if this is removed
  newLit ""

proc bar(a: static[openArray[string]] = []) =
  const tmp = foo(a)

assert compiles(bar())

Copy link
Contributor

github-actions bot commented Nov 4, 2023

🐧 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
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

IR

Compiled filesize 0 bytes (0 bytes)

Stats

  • Started 2023-11-04T10:13:05
  • Finished 2023-11-04T10:13:05
  • Duration

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("macros")
    )
  ),
  nnkMacroDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkBracketExpr.newTree(
          newIdentNode("openArray"),
          newIdentNode("string")
        ),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("a")
      ),
      nnkCommand.newTree(
        newIdentNode("newLit"),
        newLit("")
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("bar"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkBracketExpr.newTree(
          newIdentNode("static"),
          nnkBracketExpr.newTree(
            newIdentNode("openArray"),
            newIdentNode("string")
          )
        ),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkConstSection.newTree(
        nnkConstDef.newTree(
          newIdentNode("tmp"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("foo"),
            newIdentNode("a")
          )
        )
      )
    )
  ),
  nnkCommand.newTree(
    newIdentNode("assert"),
    nnkCall.newTree(
      newIdentNode("compiles"),
      nnkCall.newTree(
        newIdentNode("bar")
      )
    )
  )
)
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/temp.nim temp
/home/runner/.choosenim/toolchains/nim-2.0.0/lib/std/assertions.nim failedAssertImpl
/home/runner/.choosenim/toolchains/nim-2.0.0/lib/std/assertions.nim raiseAssert
/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/fatal.nim sysFatal
Error: unhandled exception: /home/runner/work/Nim/Nim/temp.nim(7, 1) `compiles(bar())`  [AssertionDefect]
Error: execution of an external program failed: '/home/runner/work/Nim/Nim/temp'
assertions.nim(34)       raiseAssert
Error: unhandled exception: options.nim(664, 5) `false` errGenerated [AssertionDefect]

IR

Compiled filesize 91.57 Kb (93,768 bytes)
#define NIM_INTBITS 64
#include "nimbase.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;
struct NimStrPayload {
 NI cap;
 NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
 NI len;
 NimStrPayload* p;
};
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__stdZassertions_u310)(NimStringV2 msg_p0);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
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, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
static const struct {
NI cap; NIM_CHAR data[59+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 59 | NIM_STRLIT_FLAG, "/home/runner/work/Nim/Nim/temp.nim(7, 1) `compiles(bar())` " };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {59, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4389;
extern NIM_THREADVAR TFrame* framePtr__system_u4006;
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
 NIM_BOOL* result;
 result = (NIM_BOOL*)0;
 result = (&nimInErrorMode__system_u4389);
 return result;
}
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 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) {
{
NIM_BOOL* nimErr_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
 {
  if (!NIM_TRUE) goto LA3_;
  failedAssertImpl__stdZassertions_u310(TM__SRd76hP9cMfCzdUO857UhQQ_3);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
LA3_: ;
 BeforeRet_: ;
 nimTestErrorFlag();
 popFrame();
}
}

Stats

  • Started 2023-11-04T10:13:06
  • Finished 2023-11-04T10:13:06
  • Duration

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("macros")
    )
  ),
  nnkMacroDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkBracketExpr.newTree(
          newIdentNode("openArray"),
          newIdentNode("string")
        ),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("a")
      ),
      nnkCommand.newTree(
        newIdentNode("newLit"),
        newLit("")
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("bar"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkBracketExpr.newTree(
          newIdentNode("static"),
          nnkBracketExpr.newTree(
            newIdentNode("openArray"),
            newIdentNode("string")
          )
        ),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkConstSection.newTree(
        nnkConstDef.newTree(
          newIdentNode("tmp"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("foo"),
            newIdentNode("a")
          )
        )
      )
    )
  ),
  nnkCommand.newTree(
    newIdentNode("assert"),
    nnkCall.newTree(
      newIdentNode("compiles"),
      nnkCall.newTree(
        newIdentNode("bar")
      )
    )
  )
)
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/temp.nim temp
/home/runner/.choosenim/toolchains/nim-2.0.0/lib/std/assertions.nim failedAssertImpl
/home/runner/.choosenim/toolchains/nim-2.0.0/lib/std/assertions.nim raiseAssert
/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/fatal.nim sysFatal
Error: unhandled exception: /home/runner/work/Nim/Nim/temp.nim(7, 1) `compiles(bar())`  [AssertionDefect]
Error: execution of an external program failed: '/home/runner/work/Nim/Nim/temp'
assertions.nim(34)       raiseAssert
Error: unhandled exception: options.nim(664, 5) `false` errGenerated [AssertionDefect]

IR

Compiled filesize 91.57 Kb (93,768 bytes)
#define NIM_INTBITS 64
#include "nimbase.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;
struct NimStrPayload {
 NI cap;
 NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
 NI len;
 NimStrPayload* p;
};
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__stdZassertions_u310)(NimStringV2 msg_p0);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
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, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
static const struct {
NI cap; NIM_CHAR data[59+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 59 | NIM_STRLIT_FLAG, "/home/runner/work/Nim/Nim/temp.nim(7, 1) `compiles(bar())` " };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {59, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4389;
extern NIM_THREADVAR TFrame* framePtr__system_u4006;
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
 NIM_BOOL* result;
 result = (NIM_BOOL*)0;
 result = (&nimInErrorMode__system_u4389);
 return result;
}
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 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) {
{
NIM_BOOL* nimErr_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
 {
  if (!NIM_TRUE) goto LA3_;
  failedAssertImpl__stdZassertions_u310(TM__SRd76hP9cMfCzdUO857UhQQ_3);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
LA3_: ;
 BeforeRet_: ;
 nimTestErrorFlag();
 popFrame();
}
}

Stats

  • Started 2023-11-04T10:13:07
  • Finished 2023-11-04T10:13:07
  • Duration

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("macros")
    )
  ),
  nnkMacroDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkBracketExpr.newTree(
          newIdentNode("openArray"),
          newIdentNode("string")
        ),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("a")
      ),
      nnkCommand.newTree(
        newIdentNode("newLit"),
        newLit("")
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("bar"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkBracketExpr.newTree(
          newIdentNode("static"),
          nnkBracketExpr.newTree(
            newIdentNode("openArray"),
            newIdentNode("string")
          )
        ),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkConstSection.newTree(
        nnkConstDef.newTree(
          newIdentNode("tmp"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("foo"),
            newIdentNode("a")
          )
        )
      )
    )
  ),
  nnkCommand.newTree(
    newIdentNode("assert"),
    nnkCall.newTree(
      newIdentNode("compiles"),
      nnkCall.newTree(
        newIdentNode("bar")
      )
    )
  )
)
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/temp.nim temp
/home/runner/.choosenim/toolchains/nim-1.6.14/lib/system/assertions.nim failedAssertImpl
/home/runner/.choosenim/toolchains/nim-1.6.14/lib/system/assertions.nim raiseAssert
/home/runner/.choosenim/toolchains/nim-1.6.14/lib/system/fatal.nim sysFatal
Error: unhandled exception: /home/runner/work/Nim/Nim/temp.nim(7, 8) `compiles(bar())`  [AssertionDefect]
Error: execution of an external program failed: '/home/runner/work/Nim/Nim/temp '
fatal.nim(54)            sysFatal
Error: unhandled exception: options.nim(645, 14) `false` errGenerated [AssertionDefect]

IR

Compiled filesize 95.85 Kb (98,152 bytes)
#define NIM_INTBITS 64
#include "nimbase.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 NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__systemZassertions_56)(NimStringDesc* msg);
static N_INLINE(void, initStackBottomWith)(void* locals);
N_LIB_PRIVATE N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom);
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(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_DatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
STRING_LITERAL(TM__SRd76hP9cMfCzdUO857UhQQ_2, "/home/runner/work/Nim/Nim/temp.nim(7, 8) `compiles(bar())` ", 59);
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, initStackBottomWith)(void* locals) {
 nimGC_setStackBottom(locals);
}
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 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) {
{
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
 {
  if (!NIM_TRUE) goto LA3_;
  failedAssertImpl__systemZassertions_56(((NimStringDesc*) &TM__SRd76hP9cMfCzdUO857UhQQ_2));
 }
 LA3_: ;
 popFrame();
}
}

Stats

  • Started 2023-11-04T10:13:10
  • Finished 2023-11-04T10:13:11
  • Duration

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("macros")
    )
  ),
  nnkMacroDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkBracketExpr.newTree(
          newIdentNode("openArray"),
          newIdentNode("string")
        ),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("a")
      ),
      nnkCommand.newTree(
        newIdentNode("newLit"),
        newLit("")
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("bar"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkBracketExpr.newTree(
          newIdentNode("static"),
          nnkBracketExpr.newTree(
            newIdentNode("openArray"),
            newIdentNode("string")
          )
        ),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkConstSection.newTree(
        nnkConstDef.newTree(
          newIdentNode("tmp"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("foo"),
            newIdentNode("a")
          )
        )
      )
    )
  ),
  nnkCommand.newTree(
    newIdentNode("assert"),
    nnkCall.newTree(
      newIdentNode("compiles"),
      nnkCall.newTree(
        newIdentNode("bar")
      )
    )
  )
)
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/temp.nim temp
/home/runner/.choosenim/toolchains/nim-1.4.8/lib/system/assertions.nim failedAssertImpl
/home/runner/.choosenim/toolchains/nim-1.4.8/lib/system/assertions.nim raiseAssert
/home/runner/.choosenim/toolchains/nim-1.4.8/lib/system/fatal.nim sysFatal
Error: unhandled exception: /home/runner/work/Nim/Nim/temp.nim(7, 8) `compiles(bar())`  [AssertionDefect]
Error: execution of an external program failed: '/home/runner/work/Nim/Nim/temp '

IR

Compiled filesize 91.68 Kb (93,880 bytes)
#define NIM_INTBITS 64
#include "nimbase.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 NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__W9cjVocn1tjhW7p7xohJj6A)(NimStringDesc* msg);
static N_INLINE(void, initStackBottomWith)(void* locals);
N_LIB_PRIVATE N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom);
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(void, systemDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
STRING_LITERAL(TM__SRd76hP9cMfCzdUO857UhQQ_2, "/home/runner/work/Nim/Nim/temp.nim(7, 8) `compiles(bar())` ", 59);
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, initStackBottomWith)(void* locals) {
 nimGC_setStackBottom(locals);
}
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 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) {
{
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
 {
  if (!NIM_TRUE) goto LA3_;
  failedAssertImpl__W9cjVocn1tjhW7p7xohJj6A(((NimStringDesc*) &TM__SRd76hP9cMfCzdUO857UhQQ_2));
 }
 LA3_: ;
 popFrame();
}
}

Stats

  • Started 2023-11-04T10:13:13
  • Finished 2023-11-04T10:13:13
  • Duration

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("macros")
    )
  ),
  nnkMacroDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkBracketExpr.newTree(
          newIdentNode("openArray"),
          newIdentNode("string")
        ),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("a")
      ),
      nnkCommand.newTree(
        newIdentNode("newLit"),
        newLit("")
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("bar"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkBracketExpr.newTree(
          newIdentNode("static"),
          nnkBracketExpr.newTree(
            newIdentNode("openArray"),
            newIdentNode("string")
          )
        ),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkConstSection.newTree(
        nnkConstDef.newTree(
          newIdentNode("tmp"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("foo"),
            newIdentNode("a")
          )
        )
      )
    )
  ),
  nnkCommand.newTree(
    newIdentNode("assert"),
    nnkCall.newTree(
      newIdentNode("compiles"),
      nnkCall.newTree(
        newIdentNode("bar")
      )
    )
  )
)
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/temp.nim temp
/home/runner/.choosenim/toolchains/nim-1.2.18/lib/system/assertions.nim failedAssertImpl
/home/runner/.choosenim/toolchains/nim-1.2.18/lib/system/assertions.nim raiseAssert
/home/runner/.choosenim/toolchains/nim-1.2.18/lib/system/fatal.nim sysFatal
Error: unhandled exception: /home/runner/work/Nim/Nim/temp.nim(7, 8) `compiles(bar())`  [AssertionError]
Error: execution of an external program failed: '/home/runner/work/Nim/Nim/temp '

IR

Compiled filesize 91.41 Kb (93,600 bytes)
#define NIM_INTBITS 64
#include "nimbase.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 NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__W9cjVocn1tjhW7p7xohJj6A)(NimStringDesc* msg);
static N_INLINE(void, initStackBottomWith)(void* locals);
N_LIB_PRIVATE N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom);
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(void, systemDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
STRING_LITERAL(TM__SRd76hP9cMfCzdUO857UhQQ_2, "/home/runner/work/Nim/Nim/temp.nim(7, 8) `compiles(bar())` ", 59);
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, initStackBottomWith)(void* locals) {
 nimGC_setStackBottom(locals);
}
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 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) {
{
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
 {
  if (!NIM_TRUE) goto LA3_;
  failedAssertImpl__W9cjVocn1tjhW7p7xohJj6A(((NimStringDesc*) &TM__SRd76hP9cMfCzdUO857UhQQ_2));
 }
 LA3_: ;
 popFrame();
}
}

Stats

  • Started 2023-11-04T10:13:16
  • Finished 2023-11-04T10:13:16
  • Duration

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("macros")
    )
  ),
  nnkMacroDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkBracketExpr.newTree(
          newIdentNode("openArray"),
          newIdentNode("string")
        ),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("a")
      ),
      nnkCommand.newTree(
        newIdentNode("newLit"),
        newLit("")
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("bar"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkBracketExpr.newTree(
          newIdentNode("static"),
          nnkBracketExpr.newTree(
            newIdentNode("openArray"),
            newIdentNode("string")
          )
        ),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkConstSection.newTree(
        nnkConstDef.newTree(
          newIdentNode("tmp"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("foo"),
            newIdentNode("a")
          )
        )
      )
    )
  ),
  nnkCommand.newTree(
    newIdentNode("assert"),
    nnkCall.newTree(
      newIdentNode("compiles"),
      nnkCall.newTree(
        newIdentNode("bar")
      )
    )
  )
)
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
/home/runner/work/Nim/Nim/temp.nim temp
/home/runner/.choosenim/toolchains/nim-1.0.10/lib/system/assertions.nim failedAssertImpl
/home/runner/.choosenim/toolchains/nim-1.0.10/lib/system/assertions.nim raiseAssert
/home/runner/.choosenim/toolchains/nim-1.0.10/lib/system/fatal.nim sysFatal
Error: unhandled exception: /home/runner/work/Nim/Nim/temp.nim(7, 8) `compiles(bar())`  [AssertionError]
Error: execution of an external program failed: '/home/runner/work/Nim/Nim/temp '

IR

Compiled filesize 86.46 Kb (88,536 bytes)
#define NIM_INTBITS 64
#include "nimbase.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 NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__W9cjVocn1tjhW7p7xohJj6A)(NimStringDesc* msg);
static N_INLINE(void, initStackBottomWith)(void* locals);
N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom);
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(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;
STRING_LITERAL(TM__SRd76hP9cMfCzdUO857UhQQ_2, "/home/runner/work/Nim/Nim/temp.nim(7, 8) `compiles(bar())` ", 59);
static N_INLINE(void, initStackBottomWith)(void* locals) {	nimGC_setStackBottom(locals);
}
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;
}
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) {
{
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
 {
  if (!NIM_TRUE) goto LA3_;
  failedAssertImpl__W9cjVocn1tjhW7p7xohJj6A(((NimStringDesc*) &TM__SRd76hP9cMfCzdUO857UhQQ_2));
 }
 LA3_: ;
 popFrame();
}
}

Stats

  • Started 2023-11-04T10:13:19
  • Finished 2023-11-04T10:13:19
  • Duration

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("macros")
    )
  ),
  nnkMacroDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkBracketExpr.newTree(
          newIdentNode("openArray"),
          newIdentNode("string")
        ),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("a")
      ),
      nnkCommand.newTree(
        newIdentNode("newLit"),
        newLit("")
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("bar"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkBracketExpr.newTree(
          newIdentNode("static"),
          nnkBracketExpr.newTree(
            newIdentNode("openArray"),
            newIdentNode("string")
          )
        ),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkConstSection.newTree(
        nnkConstDef.newTree(
          newIdentNode("tmp"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("foo"),
            newIdentNode("a")
          )
        )
      )
    )
  ),
  nnkCommand.newTree(
    newIdentNode("assert"),
    nnkCall.newTree(
      newIdentNode("compiles"),
      nnkCall.newTree(
        newIdentNode("bar")
      )
    )
  )
)
Stats
  • GCC 11.4.0
  • Clang 14.0.0
  • NodeJS 18.2
  • Created 2023-11-04T10:12:34Z
  • Comments 1
  • 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 17 minutes bisecting 7 commits at 0 commits per second

@ringabout
Copy link
Member

!nim c --gc:orc

import std/macros

macro foo(a: openArray[string] = []): string =
  echo a # Segfault doesn't happen if this is removed
  newLit ""

proc bar(a: static[openArray[string]] = []) =
  const tmp = foo(a)

assert not compiles(bar())

Copy link
Contributor

github-actions bot commented Nov 4, 2023

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

Output

Error: Command failed: nim c --gc:orc -d:nimArcDebug -d:nimArcIds  --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
command line(1, 2) Warning: `gc:option` is deprecated; use `mm:option` instead [Deprecated]
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

IR

Compiled filesize 0 bytes (0 bytes)

Stats

  • Started 2023-11-04T10:42:52
  • Finished 2023-11-04T10:42:53
  • Duration

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("macros")
    )
  ),
  nnkMacroDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkBracketExpr.newTree(
          newIdentNode("openArray"),
          newIdentNode("string")
        ),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("a")
      ),
      nnkCommand.newTree(
        newIdentNode("newLit"),
        newLit("")
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("bar"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkBracketExpr.newTree(
          newIdentNode("static"),
          nnkBracketExpr.newTree(
            newIdentNode("openArray"),
            newIdentNode("string")
          )
        ),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkConstSection.newTree(
        nnkConstDef.newTree(
          newIdentNode("tmp"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("foo"),
            newIdentNode("a")
          )
        )
      )
    )
  ),
  nnkCommand.newTree(
    newIdentNode("assert"),
    nnkPrefix.newTree(
      newIdentNode("not"),
      nnkCall.newTree(
        newIdentNode("compiles"),
        nnkCall.newTree(
          newIdentNode("bar")
        )
      )
    )
  )
)
stable 👍 OK

Output


IR

Compiled filesize 96.41 Kb (98,728 bytes)
#define NIM_INTBITS 64
#include "nimbase.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;
struct NimStrPayload {
 NI cap;
 NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
 NI len;
 NimStrPayload* p;
};
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__stdZassertions_u310)(NimStringV2 msg_p0);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u5021)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
static const struct {
NI cap; NIM_CHAR data[63+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 63 | NIM_STRLIT_FLAG, "/home/runner/work/Nim/Nim/temp.nim(7, 1) `not compiles(bar())` " };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {63, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4803;
extern NIM_THREADVAR TFrame* framePtr__system_u4420;
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
 NIM_BOOL* result;
 result = (NIM_BOOL*)0;
 result = (&nimInErrorMode__system_u4803);
 return result;
}
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
 {
  if (!(framePtr__system_u4420 == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s_p0).calldepth = ((NI16)0);
 }
 goto LA1_;
LA3_: ;
 {
  (*s_p0).calldepth = (NI16)((*framePtr__system_u4420).calldepth + ((NI16)1));
 }
LA1_: ;
 (*s_p0).prev = framePtr__system_u4420;
 framePtr__system_u4420 = s_p0;
 {
  if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
  callDepthLimitReached__system_u5021();
 }
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__system_u4420 = (*framePtr__system_u4420).prev;
}
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) {
{
NIM_BOOL* nimErr_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
 {
  if (!NIM_FALSE) goto LA3_;
  failedAssertImpl__stdZassertions_u310(TM__SRd76hP9cMfCzdUO857UhQQ_3);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
LA3_: ;
 BeforeRet_: ;
 nimTestErrorFlag();
 popFrame();
}
}

Stats

  • Started 2023-11-04T10:42:53
  • Finished 2023-11-04T10:42:54
  • Duration
2.0.0 👍 OK

Output


IR

Compiled filesize 96.41 Kb (98,728 bytes)
#define NIM_INTBITS 64
#include "nimbase.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;
struct NimStrPayload {
 NI cap;
 NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
 NI len;
 NimStrPayload* p;
};
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__stdZassertions_u310)(NimStringV2 msg_p0);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u5021)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
static const struct {
NI cap; NIM_CHAR data[63+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 63 | NIM_STRLIT_FLAG, "/home/runner/work/Nim/Nim/temp.nim(7, 1) `not compiles(bar())` " };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {63, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4803;
extern NIM_THREADVAR TFrame* framePtr__system_u4420;
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
 NIM_BOOL* result;
 result = (NIM_BOOL*)0;
 result = (&nimInErrorMode__system_u4803);
 return result;
}
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
 {
  if (!(framePtr__system_u4420 == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s_p0).calldepth = ((NI16)0);
 }
 goto LA1_;
LA3_: ;
 {
  (*s_p0).calldepth = (NI16)((*framePtr__system_u4420).calldepth + ((NI16)1));
 }
LA1_: ;
 (*s_p0).prev = framePtr__system_u4420;
 framePtr__system_u4420 = s_p0;
 {
  if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
  callDepthLimitReached__system_u5021();
 }
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__system_u4420 = (*framePtr__system_u4420).prev;
}
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) {
{
NIM_BOOL* nimErr_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
 {
  if (!NIM_FALSE) goto LA3_;
  failedAssertImpl__stdZassertions_u310(TM__SRd76hP9cMfCzdUO857UhQQ_3);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
LA3_: ;
 BeforeRet_: ;
 nimTestErrorFlag();
 popFrame();
}
}

Stats

  • Started 2023-11-04T10:42:54
  • Finished 2023-11-04T10:42:55
  • Duration
1.6.14 👍 OK

Output


IR

Compiled filesize 90.51 Kb (92,680 bytes)
#define NIM_INTBITS 64
#include "nimbase.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 NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
struct NimStrPayload {
NI cap;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
NI len;
NimStrPayload* p;
};
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__systemZassertions_66)(NimStringV2 msg);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
static N_INLINE(void, nimFrame)(TFrame* s);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_4808)(void);
static N_INLINE(void, popFrame)(void);
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);
static const struct {
NI cap; NIM_CHAR data[63+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 63 | NIM_STRLIT_FLAG, "/home/runner/work/Nim/Nim/temp.nim(7, 1) `not compiles(bar())` " };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {63, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
extern NIM_BOOL nimInErrorMode__system_4637;
extern TFrame* framePtr__system_4286;
extern TFrame* framePtr__system_4286;
extern TFrame* framePtr__system_4286;
extern TFrame* framePtr__system_4286;
extern TFrame* framePtr__system_4286;
extern TFrame* framePtr__system_4286;
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
 NIM_BOOL* result;
 result = (NIM_BOOL*)0;
 result = (&nimInErrorMode__system_4637);
 return result;
}
static N_INLINE(void, nimFrame)(TFrame* s) {
 {
  if (!(framePtr__system_4286 == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s).calldepth = ((NI16) 0);
 }
 goto LA1_;
 LA3_: ;
 {
  (*s).calldepth = (NI16)((*framePtr__system_4286).calldepth + ((NI16) 1));
 }
 LA1_: ;
 (*s).prev = framePtr__system_4286;
 framePtr__system_4286 = s;
 {
  if (!((*s).calldepth == ((NI16) 2000))) goto LA8_;
  callDepthLimitReached__system_4808();
 }
 LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__system_4286 = (*framePtr__system_4286).prev;
}
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) {
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_DatInit000();
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_Init000();
 PreMainInner();
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
 NimMainModule();
}
N_CDECL(void, NimMain)(void) {
 PreMain();
 NimMainInner();
}
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) {
{
NIM_BOOL* nimErr_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
 {
  if (!NIM_FALSE) goto LA3_;
  failedAssertImpl__systemZassertions_66(TM__SRd76hP9cMfCzdUO857UhQQ_3);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
 LA3_: ;
 BeforeRet_: ;
 nimTestErrorFlag();
 popFrame();
}
}

Stats

  • Started 2023-11-04T10:42:59
  • Finished 2023-11-04T10:43:00
  • Duration
1.4.8 👎 FAIL

Output

Error: Command failed: nim c --gc:orc -d:nimArcDebug -d:nimArcIds  --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/.choosenim/toolchains/nim-1.4.8/lib/system/bitmasks.nim(13, 3) Error: redefinition of 'PageShift'; previous declaration here: /home/runner/.choosenim/toolchains/nim-1.4.8/lib/system/bitmasks.nim(13, 3)

IR

Compiled filesize 90.51 Kb (92,680 bytes)
#define NIM_INTBITS 64
#include "nimbase.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 NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
struct NimStrPayload {
NI cap;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
NI len;
NimStrPayload* p;
};
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__systemZassertions_66)(NimStringV2 msg);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
static N_INLINE(void, nimFrame)(TFrame* s);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_4808)(void);
static N_INLINE(void, popFrame)(void);
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);
static const struct {
NI cap; NIM_CHAR data[63+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 63 | NIM_STRLIT_FLAG, "/home/runner/work/Nim/Nim/temp.nim(7, 1) `not compiles(bar())` " };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {63, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
extern NIM_BOOL nimInErrorMode__system_4637;
extern TFrame* framePtr__system_4286;
extern TFrame* framePtr__system_4286;
extern TFrame* framePtr__system_4286;
extern TFrame* framePtr__system_4286;
extern TFrame* framePtr__system_4286;
extern TFrame* framePtr__system_4286;
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
 NIM_BOOL* result;
 result = (NIM_BOOL*)0;
 result = (&nimInErrorMode__system_4637);
 return result;
}
static N_INLINE(void, nimFrame)(TFrame* s) {
 {
  if (!(framePtr__system_4286 == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s).calldepth = ((NI16) 0);
 }
 goto LA1_;
 LA3_: ;
 {
  (*s).calldepth = (NI16)((*framePtr__system_4286).calldepth + ((NI16) 1));
 }
 LA1_: ;
 (*s).prev = framePtr__system_4286;
 framePtr__system_4286 = s;
 {
  if (!((*s).calldepth == ((NI16) 2000))) goto LA8_;
  callDepthLimitReached__system_4808();
 }
 LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__system_4286 = (*framePtr__system_4286).prev;
}
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) {
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_DatInit000();
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_Init000();
 PreMainInner();
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
 NimMainModule();
}
N_CDECL(void, NimMain)(void) {
 PreMain();
 NimMainInner();
}
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) {
{
NIM_BOOL* nimErr_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
 {
  if (!NIM_FALSE) goto LA3_;
  failedAssertImpl__systemZassertions_66(TM__SRd76hP9cMfCzdUO857UhQQ_3);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
 LA3_: ;
 BeforeRet_: ;
 nimTestErrorFlag();
 popFrame();
}
}

Stats

  • Started 2023-11-04T10:43:03
  • Finished 2023-11-04T10:43:03
  • Duration

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("macros")
    )
  ),
  nnkMacroDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkBracketExpr.newTree(
          newIdentNode("openArray"),
          newIdentNode("string")
        ),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("a")
      ),
      nnkCommand.newTree(
        newIdentNode("newLit"),
        newLit("")
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("bar"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkBracketExpr.newTree(
          newIdentNode("static"),
          nnkBracketExpr.newTree(
            newIdentNode("openArray"),
            newIdentNode("string")
          )
        ),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkConstSection.newTree(
        nnkConstDef.newTree(
          newIdentNode("tmp"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("foo"),
            newIdentNode("a")
          )
        )
      )
    )
  ),
  nnkCommand.newTree(
    newIdentNode("assert"),
    nnkPrefix.newTree(
      newIdentNode("not"),
      nnkCall.newTree(
        newIdentNode("compiles"),
        nnkCall.newTree(
          newIdentNode("bar")
        )
      )
    )
  )
)
1.2.18 👍 OK

Output


IR

Compiled filesize 82.57 Kb (84,552 bytes)
#define NIM_INTBITS 64
#include "nimbase.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 NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
struct NimStrPayload {
NI cap;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
NI len;
NimStrPayload* p;
};
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__W9cjVocn1tjhW7p7xohJj6A)(NimStringV2 msg);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
static N_INLINE(void, initStackBottomWith)(void* locals);
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(void, systemDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
static const struct {
NI cap; NIM_CHAR data[63+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 63 | NIM_STRLIT_FLAG, "/home/runner/work/Nim/Nim/temp.nim(7, 1) `not compiles(bar())` " };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {63, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
extern NIM_BOOL nimInErrorMode__759bT87luu8XGcbkw13FUjA;
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(NIM_BOOL*, nimErrorFlag)(void) {
 NIM_BOOL* result;
 result = (NIM_BOOL*)0;
 result = (&nimInErrorMode__759bT87luu8XGcbkw13FUjA);
 return result;
}
static N_INLINE(void, initStackBottomWith)(void* locals) {
}
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 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) {
{
NIM_BOOL* nimErr_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
 {
  if (!NIM_FALSE) goto LA3_;
  failedAssertImpl__W9cjVocn1tjhW7p7xohJj6A(TM__SRd76hP9cMfCzdUO857UhQQ_3);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
 LA3_: ;
 BeforeRet_: ;
 nimTestErrorFlag();
 popFrame();
}
}

Stats

  • Started 2023-11-04T10:43:07
  • Finished 2023-11-04T10:43:08
  • Duration
1.0.10 👎 FAIL

Output

Error: Command failed: nim c --gc:orc -d:nimArcDebug -d:nimArcIds  --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
command line(1, 2) Error: 'none', 'boehm' or 'refc' expected, but 'orc' found

IR

Compiled filesize 82.57 Kb (84,552 bytes)
#define NIM_INTBITS 64
#include "nimbase.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 NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
struct NimStrPayload {
NI cap;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
NI len;
NimStrPayload* p;
};
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__W9cjVocn1tjhW7p7xohJj6A)(NimStringV2 msg);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
static N_INLINE(void, initStackBottomWith)(void* locals);
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(void, systemDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
static const struct {
NI cap; NIM_CHAR data[63+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 63 | NIM_STRLIT_FLAG, "/home/runner/work/Nim/Nim/temp.nim(7, 1) `not compiles(bar())` " };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {63, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
extern NIM_BOOL nimInErrorMode__759bT87luu8XGcbkw13FUjA;
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(NIM_BOOL*, nimErrorFlag)(void) {
 NIM_BOOL* result;
 result = (NIM_BOOL*)0;
 result = (&nimInErrorMode__759bT87luu8XGcbkw13FUjA);
 return result;
}
static N_INLINE(void, initStackBottomWith)(void* locals) {
}
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 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) {
{
NIM_BOOL* nimErr_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
 {
  if (!NIM_FALSE) goto LA3_;
  failedAssertImpl__W9cjVocn1tjhW7p7xohJj6A(TM__SRd76hP9cMfCzdUO857UhQQ_3);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
 LA3_: ;
 BeforeRet_: ;
 nimTestErrorFlag();
 popFrame();
}
}

Stats

  • Started 2023-11-04T10:43:10
  • Finished 2023-11-04T10:43:10
  • Duration

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("macros")
    )
  ),
  nnkMacroDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkBracketExpr.newTree(
          newIdentNode("openArray"),
          newIdentNode("string")
        ),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("a")
      ),
      nnkCommand.newTree(
        newIdentNode("newLit"),
        newLit("")
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("bar"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkBracketExpr.newTree(
          newIdentNode("static"),
          nnkBracketExpr.newTree(
            newIdentNode("openArray"),
            newIdentNode("string")
          )
        ),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkConstSection.newTree(
        nnkConstDef.newTree(
          newIdentNode("tmp"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("foo"),
            newIdentNode("a")
          )
        )
      )
    )
  ),
  nnkCommand.newTree(
    newIdentNode("assert"),
    nnkPrefix.newTree(
      newIdentNode("not"),
      nnkCall.newTree(
        newIdentNode("compiles"),
        nnkCall.newTree(
          newIdentNode("bar")
        )
      )
    )
  )
)
#8f5b90f88 ➡️ 🐛

Diagnostics

andreas rumpf introduced a bug at 2023-09-11 18:48:20 +0200 on commit #8f5b90f88 with message:

produce better code for object constructions and 'result' [backport] (#22668)

The bug is in the files:

compiler/ccgexprs.nim
compiler/cgen.nim
tests/misc/trunner.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-04T10:42:13Z
  • Comments 3
  • Commands nim c --gc:orc -d:nimArcDebug -d:nimArcIds --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 15 minutes bisecting 294 commits at 19 commits per second

@ringabout
Copy link
Member

!nim c --gc:orc

import std/macros

macro foo(a: openArray[string] = []): string =
  echo a # Segfault doesn't happen if this is removed
  newLit ""

proc bar(a: static[openArray[string]] = []) =
  const tmp = foo(a)

assert not compiles(bar())

Copy link
Contributor

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

Output

Error: Command failed: nim c --gc:orc -d:nimArcDebug -d:nimArcIds  --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
command line(1, 2) Warning: `gc:option` is deprecated; use `mm:option` instead [Deprecated]
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

IR

Compiled filesize 0 bytes (0 bytes)

Stats

  • Started 2023-11-23T12:57:30
  • Finished 2023-11-23T12:57:30
  • Duration

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("macros")
    )
  ),
  nnkMacroDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkBracketExpr.newTree(
          newIdentNode("openArray"),
          newIdentNode("string")
        ),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("a")
      ),
      nnkCommand.newTree(
        newIdentNode("newLit"),
        newLit("")
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("bar"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkBracketExpr.newTree(
          newIdentNode("static"),
          nnkBracketExpr.newTree(
            newIdentNode("openArray"),
            newIdentNode("string")
          )
        ),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkConstSection.newTree(
        nnkConstDef.newTree(
          newIdentNode("tmp"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("foo"),
            newIdentNode("a")
          )
        )
      )
    )
  ),
  nnkCommand.newTree(
    newIdentNode("assert"),
    nnkPrefix.newTree(
      newIdentNode("not"),
      nnkCall.newTree(
        newIdentNode("compiles"),
        nnkCall.newTree(
          newIdentNode("bar")
        )
      )
    )
  )
)
stable 👍 OK

Output


IR

Compiled filesize 96.41 Kb (98,728 bytes)
#define NIM_INTBITS 64
#include "nimbase.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;
struct NimStrPayload {
 NI cap;
 NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
 NI len;
 NimStrPayload* p;
};
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__stdZassertions_u310)(NimStringV2 msg_p0);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u5021)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
static const struct {
NI cap; NIM_CHAR data[63+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 63 | NIM_STRLIT_FLAG, "/home/runner/work/Nim/Nim/temp.nim(7, 1) `not compiles(bar())` " };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {63, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4803;
extern NIM_THREADVAR TFrame* framePtr__system_u4420;
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
 NIM_BOOL* result;
 result = (NIM_BOOL*)0;
 result = (&nimInErrorMode__system_u4803);
 return result;
}
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
 {
  if (!(framePtr__system_u4420 == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s_p0).calldepth = ((NI16)0);
 }
 goto LA1_;
LA3_: ;
 {
  (*s_p0).calldepth = (NI16)((*framePtr__system_u4420).calldepth + ((NI16)1));
 }
LA1_: ;
 (*s_p0).prev = framePtr__system_u4420;
 framePtr__system_u4420 = s_p0;
 {
  if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
  callDepthLimitReached__system_u5021();
 }
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__system_u4420 = (*framePtr__system_u4420).prev;
}
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) {
{
NIM_BOOL* nimErr_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
 {
  if (!NIM_FALSE) goto LA3_;
  failedAssertImpl__stdZassertions_u310(TM__SRd76hP9cMfCzdUO857UhQQ_3);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
LA3_: ;
 BeforeRet_: ;
 nimTestErrorFlag();
 popFrame();
}
}

Stats

  • Started 2023-11-23T12:57:31
  • Finished 2023-11-23T12:57:31
  • Duration
2.0.0 👍 OK

Output


IR

Compiled filesize 96.41 Kb (98,728 bytes)
#define NIM_INTBITS 64
#include "nimbase.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;
struct NimStrPayload {
 NI cap;
 NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
 NI len;
 NimStrPayload* p;
};
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__stdZassertions_u310)(NimStringV2 msg_p0);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u5021)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
static const struct {
NI cap; NIM_CHAR data[63+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 63 | NIM_STRLIT_FLAG, "/home/runner/work/Nim/Nim/temp.nim(7, 1) `not compiles(bar())` " };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {63, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4803;
extern NIM_THREADVAR TFrame* framePtr__system_u4420;
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
 NIM_BOOL* result;
 result = (NIM_BOOL*)0;
 result = (&nimInErrorMode__system_u4803);
 return result;
}
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
 {
  if (!(framePtr__system_u4420 == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s_p0).calldepth = ((NI16)0);
 }
 goto LA1_;
LA3_: ;
 {
  (*s_p0).calldepth = (NI16)((*framePtr__system_u4420).calldepth + ((NI16)1));
 }
LA1_: ;
 (*s_p0).prev = framePtr__system_u4420;
 framePtr__system_u4420 = s_p0;
 {
  if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
  callDepthLimitReached__system_u5021();
 }
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__system_u4420 = (*framePtr__system_u4420).prev;
}
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) {
{
NIM_BOOL* nimErr_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
 {
  if (!NIM_FALSE) goto LA3_;
  failedAssertImpl__stdZassertions_u310(TM__SRd76hP9cMfCzdUO857UhQQ_3);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
LA3_: ;
 BeforeRet_: ;
 nimTestErrorFlag();
 popFrame();
}
}

Stats

  • Started 2023-11-23T12:57:31
  • Finished 2023-11-23T12:57:32
  • Duration
1.6.14 👍 OK

Output


IR

Compiled filesize 90.51 Kb (92,680 bytes)
#define NIM_INTBITS 64
#include "nimbase.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 NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
struct NimStrPayload {
NI cap;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
NI len;
NimStrPayload* p;
};
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__systemZassertions_66)(NimStringV2 msg);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
static N_INLINE(void, nimFrame)(TFrame* s);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_4808)(void);
static N_INLINE(void, popFrame)(void);
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);
static const struct {
NI cap; NIM_CHAR data[63+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 63 | NIM_STRLIT_FLAG, "/home/runner/work/Nim/Nim/temp.nim(7, 1) `not compiles(bar())` " };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {63, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
extern NIM_BOOL nimInErrorMode__system_4637;
extern TFrame* framePtr__system_4286;
extern TFrame* framePtr__system_4286;
extern TFrame* framePtr__system_4286;
extern TFrame* framePtr__system_4286;
extern TFrame* framePtr__system_4286;
extern TFrame* framePtr__system_4286;
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
 NIM_BOOL* result;
 result = (NIM_BOOL*)0;
 result = (&nimInErrorMode__system_4637);
 return result;
}
static N_INLINE(void, nimFrame)(TFrame* s) {
 {
  if (!(framePtr__system_4286 == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s).calldepth = ((NI16) 0);
 }
 goto LA1_;
 LA3_: ;
 {
  (*s).calldepth = (NI16)((*framePtr__system_4286).calldepth + ((NI16) 1));
 }
 LA1_: ;
 (*s).prev = framePtr__system_4286;
 framePtr__system_4286 = s;
 {
  if (!((*s).calldepth == ((NI16) 2000))) goto LA8_;
  callDepthLimitReached__system_4808();
 }
 LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__system_4286 = (*framePtr__system_4286).prev;
}
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) {
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_DatInit000();
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_Init000();
 PreMainInner();
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
 NimMainModule();
}
N_CDECL(void, NimMain)(void) {
 PreMain();
 NimMainInner();
}
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) {
{
NIM_BOOL* nimErr_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
 {
  if (!NIM_FALSE) goto LA3_;
  failedAssertImpl__systemZassertions_66(TM__SRd76hP9cMfCzdUO857UhQQ_3);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
 LA3_: ;
 BeforeRet_: ;
 nimTestErrorFlag();
 popFrame();
}
}

Stats

  • Started 2023-11-23T12:57:34
  • Finished 2023-11-23T12:57:34
  • Duration
1.4.8 👎 FAIL

Output

Error: Command failed: nim c --gc:orc -d:nimArcDebug -d:nimArcIds  --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/.choosenim/toolchains/nim-1.4.8/lib/system/bitmasks.nim(13, 3) Error: redefinition of 'PageShift'; previous declaration here: /home/runner/.choosenim/toolchains/nim-1.4.8/lib/system/bitmasks.nim(13, 3)

IR

Compiled filesize 90.51 Kb (92,680 bytes)
#define NIM_INTBITS 64
#include "nimbase.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 NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
struct NimStrPayload {
NI cap;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
NI len;
NimStrPayload* p;
};
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__systemZassertions_66)(NimStringV2 msg);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
static N_INLINE(void, nimFrame)(TFrame* s);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_4808)(void);
static N_INLINE(void, popFrame)(void);
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);
static const struct {
NI cap; NIM_CHAR data[63+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 63 | NIM_STRLIT_FLAG, "/home/runner/work/Nim/Nim/temp.nim(7, 1) `not compiles(bar())` " };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {63, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
extern NIM_BOOL nimInErrorMode__system_4637;
extern TFrame* framePtr__system_4286;
extern TFrame* framePtr__system_4286;
extern TFrame* framePtr__system_4286;
extern TFrame* framePtr__system_4286;
extern TFrame* framePtr__system_4286;
extern TFrame* framePtr__system_4286;
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
 NIM_BOOL* result;
 result = (NIM_BOOL*)0;
 result = (&nimInErrorMode__system_4637);
 return result;
}
static N_INLINE(void, nimFrame)(TFrame* s) {
 {
  if (!(framePtr__system_4286 == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s).calldepth = ((NI16) 0);
 }
 goto LA1_;
 LA3_: ;
 {
  (*s).calldepth = (NI16)((*framePtr__system_4286).calldepth + ((NI16) 1));
 }
 LA1_: ;
 (*s).prev = framePtr__system_4286;
 framePtr__system_4286 = s;
 {
  if (!((*s).calldepth == ((NI16) 2000))) goto LA8_;
  callDepthLimitReached__system_4808();
 }
 LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__system_4286 = (*framePtr__system_4286).prev;
}
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) {
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_DatInit000();
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_Init000();
 PreMainInner();
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
 NimMainModule();
}
N_CDECL(void, NimMain)(void) {
 PreMain();
 NimMainInner();
}
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) {
{
NIM_BOOL* nimErr_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
 {
  if (!NIM_FALSE) goto LA3_;
  failedAssertImpl__systemZassertions_66(TM__SRd76hP9cMfCzdUO857UhQQ_3);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
 LA3_: ;
 BeforeRet_: ;
 nimTestErrorFlag();
 popFrame();
}
}

Stats

  • Started 2023-11-23T12:57:36
  • Finished 2023-11-23T12:57:36
  • Duration

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("macros")
    )
  ),
  nnkMacroDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkBracketExpr.newTree(
          newIdentNode("openArray"),
          newIdentNode("string")
        ),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("a")
      ),
      nnkCommand.newTree(
        newIdentNode("newLit"),
        newLit("")
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("bar"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkBracketExpr.newTree(
          newIdentNode("static"),
          nnkBracketExpr.newTree(
            newIdentNode("openArray"),
            newIdentNode("string")
          )
        ),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkConstSection.newTree(
        nnkConstDef.newTree(
          newIdentNode("tmp"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("foo"),
            newIdentNode("a")
          )
        )
      )
    )
  ),
  nnkCommand.newTree(
    newIdentNode("assert"),
    nnkPrefix.newTree(
      newIdentNode("not"),
      nnkCall.newTree(
        newIdentNode("compiles"),
        nnkCall.newTree(
          newIdentNode("bar")
        )
      )
    )
  )
)
1.2.18 👍 OK

Output


IR

Compiled filesize 82.57 Kb (84,552 bytes)
#define NIM_INTBITS 64
#include "nimbase.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 NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
struct NimStrPayload {
NI cap;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
NI len;
NimStrPayload* p;
};
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__W9cjVocn1tjhW7p7xohJj6A)(NimStringV2 msg);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
static N_INLINE(void, initStackBottomWith)(void* locals);
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(void, systemDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
static const struct {
NI cap; NIM_CHAR data[63+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 63 | NIM_STRLIT_FLAG, "/home/runner/work/Nim/Nim/temp.nim(7, 1) `not compiles(bar())` " };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {63, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
extern NIM_BOOL nimInErrorMode__759bT87luu8XGcbkw13FUjA;
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(NIM_BOOL*, nimErrorFlag)(void) {
 NIM_BOOL* result;
 result = (NIM_BOOL*)0;
 result = (&nimInErrorMode__759bT87luu8XGcbkw13FUjA);
 return result;
}
static N_INLINE(void, initStackBottomWith)(void* locals) {
}
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 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) {
{
NIM_BOOL* nimErr_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
 {
  if (!NIM_FALSE) goto LA3_;
  failedAssertImpl__W9cjVocn1tjhW7p7xohJj6A(TM__SRd76hP9cMfCzdUO857UhQQ_3);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
 LA3_: ;
 BeforeRet_: ;
 nimTestErrorFlag();
 popFrame();
}
}

Stats

  • Started 2023-11-23T12:57:39
  • Finished 2023-11-23T12:57:40
  • Duration
1.0.10 👎 FAIL

Output

Error: Command failed: nim c --gc:orc -d:nimArcDebug -d:nimArcIds  --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
command line(1, 2) Error: 'none', 'boehm' or 'refc' expected, but 'orc' found

IR

Compiled filesize 82.57 Kb (84,552 bytes)
#define NIM_INTBITS 64
#include "nimbase.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 NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
struct NimStrPayload {
NI cap;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
NI len;
NimStrPayload* p;
};
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__W9cjVocn1tjhW7p7xohJj6A)(NimStringV2 msg);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
static N_INLINE(void, initStackBottomWith)(void* locals);
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(void, systemDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
static const struct {
NI cap; NIM_CHAR data[63+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 63 | NIM_STRLIT_FLAG, "/home/runner/work/Nim/Nim/temp.nim(7, 1) `not compiles(bar())` " };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {63, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
extern NIM_BOOL nimInErrorMode__759bT87luu8XGcbkw13FUjA;
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(NIM_BOOL*, nimErrorFlag)(void) {
 NIM_BOOL* result;
 result = (NIM_BOOL*)0;
 result = (&nimInErrorMode__759bT87luu8XGcbkw13FUjA);
 return result;
}
static N_INLINE(void, initStackBottomWith)(void* locals) {
}
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 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) {
{
NIM_BOOL* nimErr_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
 {
  if (!NIM_FALSE) goto LA3_;
  failedAssertImpl__W9cjVocn1tjhW7p7xohJj6A(TM__SRd76hP9cMfCzdUO857UhQQ_3);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
 LA3_: ;
 BeforeRet_: ;
 nimTestErrorFlag();
 popFrame();
}
}

Stats

  • Started 2023-11-23T12:57:41
  • Finished 2023-11-23T12:57:41
  • Duration

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("macros")
    )
  ),
  nnkMacroDef.newTree(
    newIdentNode("foo"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkBracketExpr.newTree(
          newIdentNode("openArray"),
          newIdentNode("string")
        ),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("a")
      ),
      nnkCommand.newTree(
        newIdentNode("newLit"),
        newLit("")
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("bar"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkBracketExpr.newTree(
          newIdentNode("static"),
          nnkBracketExpr.newTree(
            newIdentNode("openArray"),
            newIdentNode("string")
          )
        ),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkConstSection.newTree(
        nnkConstDef.newTree(
          newIdentNode("tmp"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("foo"),
            newIdentNode("a")
          )
        )
      )
    )
  ),
  nnkCommand.newTree(
    newIdentNode("assert"),
    nnkPrefix.newTree(
      newIdentNode("not"),
      nnkCall.newTree(
        newIdentNode("compiles"),
        nnkCall.newTree(
          newIdentNode("bar")
        )
      )
    )
  )
)
#8f5b90f88 ➡️ 🐛

Diagnostics

andreas rumpf introduced a bug at 2023-09-11 18:48:20 +0200 on commit #8f5b90f88 with message:

produce better code for object constructions and 'result' [backport] (#22668)

The bug is in the files:

compiler/ccgexprs.nim
compiler/cgen.nim
tests/misc/trunner.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-23T12:56:59Z
  • Comments 5
  • Commands nim c --gc:orc -d:nimArcDebug -d:nimArcIds --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 52 minutes bisecting 326 commits at 6 commits per second

@ire4ever1190 ire4ever1190 changed the title Compiler segfaults when using static openArray in a macro Compiler segfaults when passing static parameter to non static macro parameter Nov 25, 2023
@ire4ever1190
Copy link
Contributor Author

ire4ever1190 commented Nov 25, 2023

When finding a workaround I found the bug wasn't specific to openArray. Seemed to be passing a static parameter to a non static parameter caused the segfault

import std/macros

macro foo(a: int): int =  # This also needs to be invalid
  echo a.intVal

proc bar(a: static[int]) =
  const tmp = foo(a)

echo compiles(bar(1)) # Only crashes when `compiles` is used?

Not too sure why my bisect found a different commit. Haven't read into how the action works but I had to bisect different to the normal process since I needed to do a full ./koch boot because if I just used ./koch temp it would always fail (since it would always compile with a version of the compiler containing the big)

@ringabout
Copy link
Member

ringabout commented Nov 30, 2023

These automatic regression testings are not accurate. I will make a round of bisect locally

@ringabout ringabout self-assigned this Nov 30, 2023
@ringabout
Copy link
Member

Now, why the former bisects are in vain. We must boot a compiler, which is the issue. I will do one more

@ringabout
Copy link
Member

Indeed, 8f5b90f88 is the cause. I have finally confirmed

@ringabout
Copy link
Member

Now I saw the reason why it failed, I'm hopeful that I will find a solution to it soon

@ringabout
Copy link
Member

Obviously, the compiler is preverted. When I'm marking semConstExpr with nodestroy, it works. In vain I was investigating allPathsAsgnResult directly. I should have made inquiry into semConstExpr first.

@ringabout
Copy link
Member

ftw, 8f5b90f88#r133974672 seems to be the cause

Araq pushed a commit that referenced this issue Feb 1, 2024
… raise which corrupts the compiler (#23271)

fixes #22909
required by #23267

```nim
proc foo: string =
  assert false
  result = ""
```

In the function `foo`, `assert false` raises an exception, which can
cause `result` to be uninitialized if the default result initialization
is optimized out
narimiran pushed a commit that referenced this issue Apr 22, 2024
… raise which corrupts the compiler (#23271)

fixes #22909
required by #23267

```nim
proc foo: string =
  assert false
  result = ""
```

In the function `foo`, `assert false` raises an exception, which can
cause `result` to be uninitialized if the default result initialization
is optimized out

(cherry picked from commit 7d97210)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants