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

Cannot compute sizeof generic type in alias #24045

Open
arnetheduck opened this issue Sep 2, 2024 · 3 comments
Open

Cannot compute sizeof generic type in alias #24045

arnetheduck opened this issue Sep 2, 2024 · 3 comments
Labels

Comments

@arnetheduck
Copy link
Contributor

Description

type ArrayBuf*[N: static int, T] = object
  buf: array[N, T]

func maxLen(T: type): int =
  sizeof(T) * 2

type MyBuf[I: type] = ArrayBuf[maxLen(I), byte]

var v: MyBuf[int]

note I: type in alias - removing it gives #24043 instead

Nim Version

2.0.8

Current Output

testit.nim(5, 9) Error: 'sizeof' requires '.importc' types to be '.completeStruct'

Expected Output

No response

Known Workarounds

No response

Additional Information

No response

@arnetheduck arnetheduck changed the title Cannot compute sizeof generic type, Cannot compute sizeof generic type in alias Sep 2, 2024
arnetheduck added a commit to status-im/nim-stew that referenced this issue Sep 2, 2024
@ringabout ringabout added the Needs Backporting/Fixed in Devel The issues can be solved via backporting label Sep 2, 2024
@metagn
Copy link
Collaborator

metagn commented Sep 2, 2024

Would guess fixed by #23983 but not sure

Probably shouldn't backport but add test case instead

@ringabout
Copy link
Member

!nim c

let code = """
type ArrayBuf*[N: static int, T] = object
  buf: array[N, T]

func maxLen(T: type): int =
  sizeof(T) * 2

type MyBuf[I: type] = ArrayBuf[maxLen(I), byte]

var v: MyBuf[int]
"""

# foo()
writeFile("test.nim", code)

import std/osproc

let (_, exitCode) = execCmdEx("nim c -r test.nim")
doAssert exitCode != 0

Copy link
Contributor

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

Output


IR

Compiled filesize 197.50 Kb (202,240 bytes)
#include "nimbase.h"
#include <string.h>
#define nimfr_(proc, file) \
TFrame FR_; \
FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
#define nimln_(n) \
FR_.line = n;
#define nimlf_(n, file) \
FR_.line = n; FR_.filename = file;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
typedef struct tyTuple__XOVT24GHXwqiEj5GCsEGCA tyTuple__XOVT24GHXwqiEj5GCsEGCA;
typedef struct tyObject_StringTableObj__0P3m7501aN2ol2UKnK1guw tyObject_StringTableObj__0P3m7501aN2ol2UKnK1guw;
struct NimStrPayload {
 NI cap;
 NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
 NI len;
 NimStrPayload* p;
};
struct tyTuple__XOVT24GHXwqiEj5GCsEGCA {
 NimStringV2 Field0;
 NI Field1;
};
typedef NU8 tySet_tyEnum_ProcessOption__9aCfVUyDFjLLn9an3vvc7WLw;
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1);
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, writeFile__stdZsyncio_u530)(NimStringV2 filename_p0, NimStringV2 content_p1);
N_LIB_PRIVATE N_NIMCALL(tyTuple__XOVT24GHXwqiEj5GCsEGCA, execCmdEx__pureZosproc_u1989)(NimStringV2 command_p0, tySet_tyEnum_ProcessOption__9aCfVUyDFjLLn9an3vvc7WLw options_p1, tyObject_StringTableObj__0P3m7501aN2ol2UKnK1guw* env_p2, NimStringV2 workingDir_p3, NimStringV2 input_p4);
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__stdZassertions_u235)(NimStringV2 msg_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___pureZosproc_u2033)(tyTuple__XOVT24GHXwqiEj5GCsEGCA* dest_p0);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4661)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
static const struct {
 NI cap;
 NIM_CHAR data[172];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = {(171 | NIM_STRLIT_FLAG), "type ArrayBuf*[N: static int, T] = object\012  buf: array[N, T]\012func maxLen(T: type): int =\012  sizeof(T) * 2\012type MyBuf[I: type] = ArrayBuf[maxLen(I), byte]\012var v: MyBuf[int]\012"};
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {171, ((NimStrPayload*) &TM__SRd76hP9cMfCzdUO857UhQQ_2)};
static const struct {
 NI cap;
 NIM_CHAR data[9];
} TM__SRd76hP9cMfCzdUO857UhQQ_4 = {(8 | NIM_STRLIT_FLAG), "test.nim"};
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_5 = {8, ((NimStrPayload*) &TM__SRd76hP9cMfCzdUO857UhQQ_4)};
static const struct {
 NI cap;
 NIM_CHAR data[18];
} TM__SRd76hP9cMfCzdUO857UhQQ_6 = {(17 | NIM_STRLIT_FLAG), "nim c -r test.nim"};
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_7 = {17, ((NimStrPayload*) &TM__SRd76hP9cMfCzdUO857UhQQ_6)};
static const struct {
 NI cap;
 NIM_CHAR data[1];
} TM__SRd76hP9cMfCzdUO857UhQQ_8 = {(0 | NIM_STRLIT_FLAG), ""};
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_9 = {0, ((NimStrPayload*) &TM__SRd76hP9cMfCzdUO857UhQQ_8)};
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_10 = {0, ((NimStrPayload*) &TM__SRd76hP9cMfCzdUO857UhQQ_8)};
static const struct {
 NI cap;
 NIM_CHAR data[59];
} TM__SRd76hP9cMfCzdUO857UhQQ_11 = {(58 | NIM_STRLIT_FLAG), "/home/runner/work/Nim/Nim/temp.nim(13, 1) `exitCode != 0` "};
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_12 = {58, ((NimStrPayload*) &TM__SRd76hP9cMfCzdUO857UhQQ_11)};
N_LIB_PRIVATE NimStringV2 code__temp_u1;
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4443;
N_LIB_PRIVATE NI exitCode__temp_u4;
extern NIM_THREADVAR TFrame* framePtr__system_u2675;
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2) {
 void* T1_;
 T1_ = (void*)0;
 T1_ = memset(a_p0, v_p1, ((size_t) (size_p2)));
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
 NIM_BOOL* result;
 result = (&nimInErrorMode__system_u4443);
 return result;
}
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
 nimSetMem__systemZmemory_u7(p_p0, ((int) 0), size_p1);
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }BeforeRet_: ;
}
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
 {
  if (!(framePtr__system_u2675 == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s_p0).calldepth = ((NI16) 0);
 }
 goto LA1_;
LA3_: ;
 {
  (*s_p0).calldepth = (NI16)((*framePtr__system_u2675).calldepth + ((NI16) 1));
 }
LA1_: ;
 (*s_p0).prev = framePtr__system_u2675;
 framePtr__system_u2675 = s_p0;
 {
  if (!((*s_p0).calldepth == ((NI16) 2000))) goto LA8_;
  callDepthLimitReached__system_u4661();
 }
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__system_u2675 = (*framePtr__system_u2675).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;
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystemdotnim_Init000();
 (*inner)();
#else
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystemdotnim_Init000();
 PreMainInner();
#endif
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
 NimMainModule();
}
N_CDECL(void, NimMain)(void) {
#if 0
 void (*volatile inner)(void);
 PreMain();
 inner = NimMainInner;
 (*inner)();
#else
 PreMain();
 NimMainInner();
#endif
}
int main(int argc, char** args, char** env) {
 cmdLine = args;
 cmdCount = argc;
 gEnv = env;
 NimMain();
 return nim_program_result;
}
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) {
{
 tyTuple__XOVT24GHXwqiEj5GCsEGCA tmpTuple;
NIM_BOOL* nimErr_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
 nimZeroMem((void*)(&tmpTuple), sizeof(tyTuple__XOVT24GHXwqiEj5GCsEGCA));
 code__temp_u1 = TM__SRd76hP9cMfCzdUO857UhQQ_3;
 writeFile__stdZsyncio_u530(TM__SRd76hP9cMfCzdUO857UhQQ_5, code__temp_u1);
 if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
 tmpTuple = execCmdEx__pureZosproc_u1989(TM__SRd76hP9cMfCzdUO857UhQQ_7, 10, ((tyObject_StringTableObj__0P3m7501aN2ol2UKnK1guw*) NIM_NIL), TM__SRd76hP9cMfCzdUO857UhQQ_9, TM__SRd76hP9cMfCzdUO857UhQQ_10);
 if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
 exitCode__temp_u4 = tmpTuple.Field1;
 {
  if (!(!((!((exitCode__temp_u4 == ((NI) 0))))))) goto LA4_;
  failedAssertImpl__stdZassertions_u235(TM__SRd76hP9cMfCzdUO857UhQQ_12);
  if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
 }
LA4_: ;
 {
  LA1_:;
 }
 {
  eqdestroy___pureZosproc_u2033((&tmpTuple));
 }
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 if (code__temp_u1.p && !(code__temp_u1.p->cap & NIM_STRLIT_FLAG)) {
deallocShared(code__temp_u1.p);
}
 BeforeRet_: ;
 nimTestErrorFlag();
 popFrame();
}
}

Stats

  • Started 2024-10-30T11:37:24
  • Finished 2024-10-30T11:37:26
  • Duration 1 mins

AST

nnkStmtList.newTree(
  nnkLetSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("code"),
      newEmptyNode(),
      newLit("  type ArrayBuf*[N: static int, T] = object\n    buf: array[N, T]\n  func maxLen(T: type): int =\n    sizeof(T) * 2\n  type MyBuf[I: type] = ArrayBuf[maxLen(I), byte]\n  var v: MyBuf[int]\n  ")
    )
  ),
  nnkCall.newTree(
    newIdentNode("writeFile"),
    newLit("test.nim"),
    newIdentNode("code")
  ),
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("osproc")
    )
  ),
  nnkLetSection.newTree(
    nnkVarTuple.newTree(
      newIdentNode("_"),
      newIdentNode("exitCode"),
      newEmptyNode(),
      nnkCall.newTree(
        newIdentNode("execCmdEx"),
        newLit("nim c -r test.nim")
      )
    )
  ),
  nnkCommand.newTree(
    newIdentNode("doAssert"),
    nnkInfix.newTree(
      newIdentNode("!="),
      newIdentNode("exitCode"),
      newLit(0)
    )
  )
)
stable 👎 FAIL

Output


IR

Compiled filesize 197.47 Kb (202,208 bytes)
#include "nimbase.h"
#include <string.h>
#define nimfr_(proc, file) \
TFrame FR_; \
FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
#define nimln_(n) \
FR_.line = n;
#define nimlf_(n, file) \
FR_.line = n; FR_.filename = file;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
typedef struct tyTuple__XOVT24GHXwqiEj5GCsEGCA tyTuple__XOVT24GHXwqiEj5GCsEGCA;
typedef struct tyObject_StringTableObj__KVv9bLPjapMDlTjtzx4W0mg tyObject_StringTableObj__KVv9bLPjapMDlTjtzx4W0mg;
struct NimStrPayload {
 NI cap;
 NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
 NI len;
 NimStrPayload* p;
};
struct tyTuple__XOVT24GHXwqiEj5GCsEGCA {
 NimStringV2 Field0;
 NI Field1;
};
typedef NU8 tySet_tyEnum_ProcessOption__9buK9a9c4r9cYSYElxqQFL3smg;
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1);
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, writeFile__stdZsyncio_u530)(NimStringV2 filename_p0, NimStringV2 content_p1);
N_LIB_PRIVATE N_NIMCALL(tyTuple__XOVT24GHXwqiEj5GCsEGCA, execCmdEx__pureZosproc_u1989)(NimStringV2 command_p0, tySet_tyEnum_ProcessOption__9buK9a9c4r9cYSYElxqQFL3smg options_p1, tyObject_StringTableObj__KVv9bLPjapMDlTjtzx4W0mg* env_p2, NimStringV2 workingDir_p3, NimStringV2 input_p4);
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__stdZassertions_u235)(NimStringV2 msg_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___pureZosproc_u2033)(tyTuple__XOVT24GHXwqiEj5GCsEGCA* dest_p0);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4655)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot2dot0atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
static const struct {
NI cap; NIM_CHAR data[171+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 171 | NIM_STRLIT_FLAG, "type ArrayBuf*[N: static int, T] = object\012  buf: array[N, T]\012func maxLen(T: type): int =\012  sizeof(T) * 2\012type MyBuf[I: type] = ArrayBuf[maxLen(I), byte]\012var v: MyBuf[int]\012" };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {171, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
static const struct {
NI cap; NIM_CHAR data[8+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_4 = { 8 | NIM_STRLIT_FLAG, "test.nim" };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_5 = {8, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_4};
static const struct {
NI cap; NIM_CHAR data[17+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_6 = { 17 | NIM_STRLIT_FLAG, "nim c -r test.nim" };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_7 = {17, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_6};
static const struct {
NI cap; NIM_CHAR data[0+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_8 = { 0 | NIM_STRLIT_FLAG, "" };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_9 = {0, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_8};
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_10 = {0, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_8};
static const struct {
NI cap; NIM_CHAR data[58+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_11 = { 58 | NIM_STRLIT_FLAG, "/home/runner/work/Nim/Nim/temp.nim(13, 1) `exitCode != 0` " };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_12 = {58, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_11};
N_LIB_PRIVATE NimStringV2 code__temp_u1;
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4437;
N_LIB_PRIVATE NI exitCode__temp_u4;
extern NIM_THREADVAR TFrame* framePtr__system_u2669;
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2) {
 void* T1_;
 T1_ = (void*)0;
 T1_ = memset(a_p0, v_p1, ((size_t) (size_p2)));
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
 NIM_BOOL* result;
 result = (&nimInErrorMode__system_u4437);
 return result;
}
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
 nimSetMem__systemZmemory_u7(p_p0, ((int)0), size_p1);
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }BeforeRet_: ;
}
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
 {
  if (!(framePtr__system_u2669 == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s_p0).calldepth = ((NI16)0);
 }
 goto LA1_;
LA3_: ;
 {
  (*s_p0).calldepth = (NI16)((*framePtr__system_u2669).calldepth + ((NI16)1));
 }
LA1_: ;
 (*s_p0).prev = framePtr__system_u2669;
 framePtr__system_u2669 = s_p0;
 {
  if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
  callDepthLimitReached__system_u4655();
 }
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__system_u2669 = (*framePtr__system_u2669).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;
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot2dot0atslibatssystemdotnim_Init000();
 (*inner)();
#else
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot2dot0atslibatssystemdotnim_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) {
{
 tyTuple__XOVT24GHXwqiEj5GCsEGCA tmpTuple;
NIM_BOOL* nimErr_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
 nimZeroMem((void*)(&tmpTuple), sizeof(tyTuple__XOVT24GHXwqiEj5GCsEGCA));
 code__temp_u1 = TM__SRd76hP9cMfCzdUO857UhQQ_3;
 writeFile__stdZsyncio_u530(TM__SRd76hP9cMfCzdUO857UhQQ_5, code__temp_u1);
 if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
 tmpTuple = execCmdEx__pureZosproc_u1989(TM__SRd76hP9cMfCzdUO857UhQQ_7, 10, ((tyObject_StringTableObj__KVv9bLPjapMDlTjtzx4W0mg*) NIM_NIL), TM__SRd76hP9cMfCzdUO857UhQQ_9, TM__SRd76hP9cMfCzdUO857UhQQ_10);
 if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
 exitCode__temp_u4 = tmpTuple.Field1;
 {
  if (!!(!((exitCode__temp_u4 == ((NI)0))))) goto LA4_;
  failedAssertImpl__stdZassertions_u235(TM__SRd76hP9cMfCzdUO857UhQQ_12);
  if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
 }
LA4_: ;
 {
  LA1_:;
 }
 {
  eqdestroy___pureZosproc_u2033((&tmpTuple));
 }
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 if (code__temp_u1.p && !(code__temp_u1.p->cap & NIM_STRLIT_FLAG)) {
deallocShared(code__temp_u1.p);
}
 BeforeRet_: ;
 nimTestErrorFlag();
 popFrame();
}
}

Stats

  • Started 2024-10-30T11:37:30
  • Finished 2024-10-30T11:37:32
  • Duration 1 mins

AST

nnkStmtList.newTree(
  nnkLetSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("code"),
      newEmptyNode(),
      newLit("  type ArrayBuf*[N: static int, T] = object\n    buf: array[N, T]\n  func maxLen(T: type): int =\n    sizeof(T) * 2\n  type MyBuf[I: type] = ArrayBuf[maxLen(I), byte]\n  var v: MyBuf[int]\n  ")
    )
  ),
  nnkCall.newTree(
    newIdentNode("writeFile"),
    newLit("test.nim"),
    newIdentNode("code")
  ),
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("osproc")
    )
  ),
  nnkLetSection.newTree(
    nnkVarTuple.newTree(
      newIdentNode("_"),
      newIdentNode("exitCode"),
      newEmptyNode(),
      nnkCall.newTree(
        newIdentNode("execCmdEx"),
        newLit("nim c -r test.nim")
      )
    )
  ),
  nnkCommand.newTree(
    newIdentNode("doAssert"),
    nnkInfix.newTree(
      newIdentNode("!="),
      newIdentNode("exitCode"),
      newLit(0)
    )
  )
)
2.0.10 👍 OK

Output


IR

Compiled filesize 197.37 Kb (202,104 bytes)
#include "nimbase.h"
#include <string.h>
#define nimfr_(proc, file) \
TFrame FR_; \
FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
#define nimfrs_(proc, file, slots, length) \
 struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename;NI len;VarSlot s[slots];} FR_; \
 FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
#define nimln_(n) \
 FR_.line = n;
#define nimlf_(n, file) \
 FR_.line = n; FR_.filename = file;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
typedef struct tyTuple__XOVT24GHXwqiEj5GCsEGCA tyTuple__XOVT24GHXwqiEj5GCsEGCA;
typedef struct tyObject_StringTableObj__p7uyWe9c2XCestpqANNVJmA tyObject_StringTableObj__p7uyWe9c2XCestpqANNVJmA;
struct NimStrPayload {
 NI cap;
 NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
 NI len;
 NimStrPayload* p;
};
struct tyTuple__XOVT24GHXwqiEj5GCsEGCA {
NimStringV2 Field0;
NI Field1;
};
typedef NU8 tySet_tyEnum_ProcessOption__1BaStJTV9bKPUjyCV79btwzQ;
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1);
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, writeFile__stdZsyncio_u530)(NimStringV2 filename_p0, NimStringV2 content_p1);
N_LIB_PRIVATE N_NIMCALL(tyTuple__XOVT24GHXwqiEj5GCsEGCA, execCmdEx__pureZosproc_u1972)(NimStringV2 command_p0, tySet_tyEnum_ProcessOption__1BaStJTV9bKPUjyCV79btwzQ options_p1, tyObject_StringTableObj__p7uyWe9c2XCestpqANNVJmA* env_p2, NimStringV2 workingDir_p3, NimStringV2 input_p4);
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__stdZassertions_u270)(NimStringV2 msg_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___pureZosproc_u2016)(tyTuple__XOVT24GHXwqiEj5GCsEGCA* dest_p0);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4620)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot10atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
static const struct {
NI cap; NIM_CHAR data[171+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 171 | NIM_STRLIT_FLAG, "type ArrayBuf*[N: static int, T] = object\012  buf: array[N, T]\012func maxLen(T: type): int =\012  sizeof(T) * 2\012type MyBuf[I: type] = ArrayBuf[maxLen(I), byte]\012var v: MyBuf[int]\012" };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {171, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
static const struct {
NI cap; NIM_CHAR data[8+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_4 = { 8 | NIM_STRLIT_FLAG, "test.nim" };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_5 = {8, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_4};
static const struct {
NI cap; NIM_CHAR data[17+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_6 = { 17 | NIM_STRLIT_FLAG, "nim c -r test.nim" };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_7 = {17, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_6};
static const struct {
NI cap; NIM_CHAR data[0+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_8 = { 0 | NIM_STRLIT_FLAG, "" };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_9 = {0, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_8};
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_10 = {0, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_8};
static const struct {
NI cap; NIM_CHAR data[58+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_11 = { 58 | NIM_STRLIT_FLAG, "/home/runner/work/Nim/Nim/temp.nim(13, 1) `exitCode != 0` " };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_12 = {58, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_11};
N_LIB_PRIVATE NimStringV2 code__temp_u1;
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4402;
N_LIB_PRIVATE NI exitCode__temp_u4;
extern NIM_THREADVAR TFrame* framePtr__system_u4059;
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2) {
 void* T1_;
 T1_ = (void*)0;
 T1_ = memset(a_p0, v_p1, ((size_t) (size_p2)));
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
 NIM_BOOL* result;
 result = (&nimInErrorMode__system_u4402);
 return result;
}
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
 nimSetMem__systemZmemory_u7(p_p0, ((int)0), size_p1);
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }BeforeRet_: ;
}
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
 {
  if (!(framePtr__system_u4059 == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s_p0).calldepth = ((NI16)0);
 }
 goto LA1_;
LA3_: ;
 {
  (*s_p0).calldepth = (NI16)((*framePtr__system_u4059).calldepth + ((NI16)1));
 }
LA1_: ;
 (*s_p0).prev = framePtr__system_u4059;
 framePtr__system_u4059 = s_p0;
 {
  if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
  callDepthLimitReached__system_u4620();
 }
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__system_u4059 = (*framePtr__system_u4059).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;
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot10atslibatssystemdotnim_Init000();
 (*inner)();
#else
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot10atslibatssystemdotnim_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) {
{
 tyTuple__XOVT24GHXwqiEj5GCsEGCA tmpTuple;
NIM_BOOL* nimErr_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
 nimZeroMem((void*)(&tmpTuple), sizeof(tyTuple__XOVT24GHXwqiEj5GCsEGCA));
 code__temp_u1 = TM__SRd76hP9cMfCzdUO857UhQQ_3;
 writeFile__stdZsyncio_u530(TM__SRd76hP9cMfCzdUO857UhQQ_5, code__temp_u1);
 if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
 tmpTuple = execCmdEx__pureZosproc_u1972(TM__SRd76hP9cMfCzdUO857UhQQ_7, 10, ((tyObject_StringTableObj__p7uyWe9c2XCestpqANNVJmA*) NIM_NIL), TM__SRd76hP9cMfCzdUO857UhQQ_9, TM__SRd76hP9cMfCzdUO857UhQQ_10);
 if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
 exitCode__temp_u4 = tmpTuple.Field1;
 {
  if (!!(!((exitCode__temp_u4 == ((NI)0))))) goto LA4_;
  failedAssertImpl__stdZassertions_u270(TM__SRd76hP9cMfCzdUO857UhQQ_12);
  if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
 }
LA4_: ;
 {
  LA1_:;
 }
 {
  eqdestroy___pureZosproc_u2016((&tmpTuple));
 }
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 if (code__temp_u1.p && !(code__temp_u1.p->cap & NIM_STRLIT_FLAG)) {
deallocShared(code__temp_u1.p);
}
 BeforeRet_: ;
 nimTestErrorFlag();
 popFrame();
}
}

Stats

  • Started 2024-10-30T11:37:35
  • Finished 2024-10-30T11:37:37
  • Duration 1 mins
2.0.0 👍 OK

Output


IR

Compiled filesize 193.19 Kb (197,824 bytes)
#include "nimbase.h"
#include <string.h>
#define nimfr_(proc, file) \
TFrame FR_; \
FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
#define nimfrs_(proc, file, slots, length) \
 struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename;NI len;VarSlot s[slots];} FR_; \
 FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
#define nimln_(n) \
 FR_.line = n;
#define nimlf_(n, file) \
 FR_.line = n; FR_.filename = file;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
typedef struct tyTuple__XOVT24GHXwqiEj5GCsEGCA tyTuple__XOVT24GHXwqiEj5GCsEGCA;
typedef struct tyObject_StringTableObj__9aQVWDBodHNhkGlutyRtcOw tyObject_StringTableObj__9aQVWDBodHNhkGlutyRtcOw;
struct NimStrPayload {
 NI cap;
 NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
 NI len;
 NimStrPayload* p;
};
struct tyTuple__XOVT24GHXwqiEj5GCsEGCA {
NimStringV2 Field0;
NI Field1;
};
typedef NU8 tySet_tyEnum_ProcessOption__OskndNPuFVug9cMKa9ct4N5w;
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1);
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, writeFile__stdZsyncio_u532)(NimStringV2 filename_p0, NimStringV2 content_p1);
N_LIB_PRIVATE N_NIMCALL(tyTuple__XOVT24GHXwqiEj5GCsEGCA, execCmdEx__pureZosproc_u2027)(NimStringV2 command_p0, tySet_tyEnum_ProcessOption__OskndNPuFVug9cMKa9ct4N5w options_p1, tyObject_StringTableObj__9aQVWDBodHNhkGlutyRtcOw* env_p2, NimStringV2 workingDir_p3, NimStringV2 input_p4);
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__stdZassertions_u310)(NimStringV2 msg_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___pureZosproc_u2071)(tyTuple__XOVT24GHXwqiEj5GCsEGCA* dest_p0);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4607)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
static const struct {
NI cap; NIM_CHAR data[171+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 171 | NIM_STRLIT_FLAG, "type ArrayBuf*[N: static int, T] = object\012  buf: array[N, T]\012func maxLen(T: type): int =\012  sizeof(T) * 2\012type MyBuf[I: type] = ArrayBuf[maxLen(I), byte]\012var v: MyBuf[int]\012" };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {171, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
static const struct {
NI cap; NIM_CHAR data[8+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_4 = { 8 | NIM_STRLIT_FLAG, "test.nim" };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_5 = {8, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_4};
static const struct {
NI cap; NIM_CHAR data[17+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_6 = { 17 | NIM_STRLIT_FLAG, "nim c -r test.nim" };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_7 = {17, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_6};
static const struct {
NI cap; NIM_CHAR data[0+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_8 = { 0 | NIM_STRLIT_FLAG, "" };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_9 = {0, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_8};
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_10 = {0, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_8};
static const struct {
NI cap; NIM_CHAR data[58+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_11 = { 58 | NIM_STRLIT_FLAG, "/home/runner/work/Nim/Nim/temp.nim(13, 1) `exitCode != 0` " };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_12 = {58, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_11};
N_LIB_PRIVATE NimStringV2 code__temp_u1;
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4389;
N_LIB_PRIVATE NI exitCode__temp_u4;
extern NIM_THREADVAR TFrame* framePtr__system_u4006;
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2) {
 void* T1_;
 T1_ = (void*)0;
 T1_ = memset(a_p0, v_p1, ((size_t) (size_p2)));
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
 NIM_BOOL* result;
 result = (NIM_BOOL*)0;
 result = (&nimInErrorMode__system_u4389);
 return result;
}
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
 nimSetMem__systemZmemory_u7(p_p0, ((int)0), size_p1);
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }BeforeRet_: ;
}
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
 {
  if (!(framePtr__system_u4006 == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s_p0).calldepth = ((NI16)0);
 }
 goto LA1_;
LA3_: ;
 {
  (*s_p0).calldepth = (NI16)((*framePtr__system_u4006).calldepth + ((NI16)1));
 }
LA1_: ;
 (*s_p0).prev = framePtr__system_u4006;
 framePtr__system_u4006 = s_p0;
 {
  if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
  callDepthLimitReached__system_u4607();
 }
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__system_u4006 = (*framePtr__system_u4006).prev;
}
N_LIB_PRIVATE 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) {
{
 tyTuple__XOVT24GHXwqiEj5GCsEGCA tmpTuple;
NIM_BOOL oldNimErrFin1_;
NIM_BOOL* nimErr_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
 nimZeroMem((void*)(&tmpTuple), sizeof(tyTuple__XOVT24GHXwqiEj5GCsEGCA));
 code__temp_u1 = TM__SRd76hP9cMfCzdUO857UhQQ_3;
 writeFile__stdZsyncio_u532(TM__SRd76hP9cMfCzdUO857UhQQ_5, code__temp_u1);
 if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
 tmpTuple = execCmdEx__pureZosproc_u2027(TM__SRd76hP9cMfCzdUO857UhQQ_7, 10, ((tyObject_StringTableObj__9aQVWDBodHNhkGlutyRtcOw*) NIM_NIL), TM__SRd76hP9cMfCzdUO857UhQQ_9, TM__SRd76hP9cMfCzdUO857UhQQ_10);
 if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
 exitCode__temp_u4 = tmpTuple.Field1;
 {
  if (!!(!((exitCode__temp_u4 == ((NI)0))))) goto LA4_;
  failedAssertImpl__stdZassertions_u310(TM__SRd76hP9cMfCzdUO857UhQQ_12);
  if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
 }
LA4_: ;
 {
  LA1_:;
 }
 {
  oldNimErrFin1_ = *nimErr_; *nimErr_ = NIM_FALSE;
  eqdestroy___pureZosproc_u2071((&tmpTuple));
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
  *nimErr_ = oldNimErrFin1_;
 }
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 if (code__temp_u1.p && !(code__temp_u1.p->cap & NIM_STRLIT_FLAG)) {
deallocShared(code__temp_u1.p);
}
 BeforeRet_: ;
 nimTestErrorFlag();
 popFrame();
}
}

Stats

  • Started 2024-10-30T11:37:40
  • Finished 2024-10-30T11:37:41
  • Duration 1 mins
1.6.20 👎 FAIL

Output


IR

Compiled filesize 210.05 Kb (215,088 bytes)
#include "nimbase.h"
#include <string.h>
#  define nimfr_(proc, file) \
 TFrame FR_; \
 FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
#  define nimfrs_(proc, file, slots, length) \
 struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename; NI len; VarSlot s[slots];} FR_; \
 FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
#  define nimln_(n, file) \
 FR_.line = n; FR_.filename = file;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct tyObject_Cell__USbPc9alteBFOfRejw0IPYQ tyObject_Cell__USbPc9alteBFOfRejw0IPYQ;
typedef struct tyObject_CellSeq__jRKHLJ9a9c5ErVSJdxK4Cpgg tyObject_CellSeq__jRKHLJ9a9c5ErVSJdxK4Cpgg;
typedef struct tyObject_GcHeap__t69aQjzxW7FmvOL7XpHLmyw tyObject_GcHeap__t69aQjzxW7FmvOL7XpHLmyw;
typedef struct tyObject_GcStack__rDlr9cRaEdNqxGR9croMEJNw tyObject_GcStack__rDlr9cRaEdNqxGR9croMEJNw;
typedef struct tyObject_MemRegion__D0dQEAx0h5Bhgc8Q6BW2Iw tyObject_MemRegion__D0dQEAx0h5Bhgc8Q6BW2Iw;
typedef struct tyObject_SmallChunk__O53kXtyFD7TDiEYwk5Td1Q tyObject_SmallChunk__O53kXtyFD7TDiEYwk5Td1Q;
typedef struct tyObject_BigChunk__yXMahKLrwWYxDO82eN9ba1w tyObject_BigChunk__yXMahKLrwWYxDO82eN9ba1w;
typedef struct tyObject_LLChunk__UJR9cDjZvibCSXo9aRj7SX9cQ tyObject_LLChunk__UJR9cDjZvibCSXo9aRj7SX9cQ;
typedef struct tyObject_IntSet__i7ywOkONvFvdahwK0NEBVQ tyObject_IntSet__i7ywOkONvFvdahwK0NEBVQ;
typedef struct tyObject_Trunk__KdFprq6T12mWzGalsCR7gg tyObject_Trunk__KdFprq6T12mWzGalsCR7gg;
typedef struct tyObject_AvlNode__HGw0Fii3rdknN9aH9aqThc3g tyObject_AvlNode__HGw0Fii3rdknN9aH9aqThc3g;
typedef struct tyObject_HeapLinks__Bw0IMvdOVqyBxxH1ZmEDeg tyObject_HeapLinks__Bw0IMvdOVqyBxxH1ZmEDeg;
typedef struct tyTuple__59a7yNnUUaLYoYgMyTxCvyA tyTuple__59a7yNnUUaLYoYgMyTxCvyA;
typedef struct tyObject_GcStat__fGBxrB5bu5S0xC9brjmfkoQ tyObject_GcStat__fGBxrB5bu5S0xC9brjmfkoQ;
typedef struct tyObject_CellSet__UY9caB79b0qIHRObBn8A4WSA tyObject_CellSet__UY9caB79b0qIHRObBn8A4WSA;
typedef struct tyObject_PageDesc__j9aIB2yRpeIkPT6e1CrFY5g tyObject_PageDesc__j9aIB2yRpeIkPT6e1CrFY5g;
typedef struct tyObject_StringTableObj__g5rx0hEIWFWSMYZo0pFkqg tyObject_StringTableObj__g5rx0hEIWFWSMYZo0pFkqg;
typedef struct tyTuple__XOVT24GHXwqiEj5GCsEGCA tyTuple__XOVT24GHXwqiEj5GCsEGCA;
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef NU8 tyEnum_TNimKind__b9brdfAMvuT12kv1MtmF3IQ;
typedef NU8 tySet_tyEnum_TNimTypeFlag__h29aLKtZInAIaLqhWRujWcA;
typedef N_NIMCALL_PTR(void, tyProc__ojoeKfW4VYIm36I9cpDTQIg) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ) (void* p);
struct TNimType {
NI size;
NI align;
tyEnum_TNimKind__b9brdfAMvuT12kv1MtmF3IQ kind;
tySet_tyEnum_TNimTypeFlag__h29aLKtZInAIaLqhWRujWcA flags;
TNimType* base;
TNimNode* node;
void* finalizer;
tyProc__ojoeKfW4VYIm36I9cpDTQIg marker;
tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ deepcopy;
};
typedef NU8 tyEnum_TNimNodeKind__K6UETQxRj3HYBl69c6NhKig;
struct TNimNode {
tyEnum_TNimNodeKind__K6UETQxRj3HYBl69c6NhKig kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
typedef N_NIMCALL_PTR(void, tyProc__T4eqaYlFJYZUv9aG9b1TV0bQ) (void);
struct tyObject_Cell__USbPc9alteBFOfRejw0IPYQ {
NI refcount;
TNimType* typ;
};
struct tyObject_GcStack__rDlr9cRaEdNqxGR9croMEJNw {
void* bottom;
};
struct tyObject_CellSeq__jRKHLJ9a9c5ErVSJdxK4Cpgg {
NI len;
NI cap;
tyObject_Cell__USbPc9alteBFOfRejw0IPYQ** d;
};
typedef tyObject_SmallChunk__O53kXtyFD7TDiEYwk5Td1Q* tyArray__am9ckwqC56M7ACKNToDQf8g[256];
typedef NU32 tyArray__BHbOSqU1t9b3Gt7K2c6fQig[24];
typedef tyObject_BigChunk__yXMahKLrwWYxDO82eN9ba1w* tyArray__dKp1AZMrWGPz9btzS7Vnpow[32];
typedef tyArray__dKp1AZMrWGPz9btzS7Vnpow tyArray__qtz48s7lyP6EI0JVCgNDLw[24];
typedef tyObject_Trunk__KdFprq6T12mWzGalsCR7gg* tyArray__n7OYK9anGXLKqT2bAWs4WmA[256];
struct tyObject_IntSet__i7ywOkONvFvdahwK0NEBVQ {
tyArray__n7OYK9anGXLKqT2bAWs4WmA data;
};
typedef tyObject_AvlNode__HGw0Fii3rdknN9aH9aqThc3g* tyArray__FZjlW9aArl8yDtsaKBHERDQ[2];
struct tyObject_AvlNode__HGw0Fii3rdknN9aH9aqThc3g {
tyArray__FZjlW9aArl8yDtsaKBHERDQ link;
NI key;
NI upperBound;
NI level;
};
struct tyTuple__59a7yNnUUaLYoYgMyTxCvyA {
tyObject_BigChunk__yXMahKLrwWYxDO82eN9ba1w* Field0;
NI Field1;
};
typedef tyTuple__59a7yNnUUaLYoYgMyTxCvyA tyArray__BxsOe7WmMYPypzw9cg9aWRFQ[30];
struct tyObject_HeapLinks__Bw0IMvdOVqyBxxH1ZmEDeg {
NI len;
tyArray__BxsOe7WmMYPypzw9cg9aWRFQ chunks;
tyObject_HeapLinks__Bw0IMvdOVqyBxxH1ZmEDeg* next;
};
struct tyObject_MemRegion__D0dQEAx0h5Bhgc8Q6BW2Iw {
NI minLargeObj;
NI maxLargeObj;
tyArray__am9ckwqC56M7ACKNToDQf8g freeSmallChunks;
NU32 flBitmap;
tyArray__BHbOSqU1t9b3Gt7K2c6fQig slBitmap;
tyArray__qtz48s7lyP6EI0JVCgNDLw matrix;
tyObject_LLChunk__UJR9cDjZvibCSXo9aRj7SX9cQ* llmem;
NI currMem;
NI maxMem;
NI freeMem;
NI occ;
NI lastSize;
tyObject_IntSet__i7ywOkONvFvdahwK0NEBVQ chunkStarts;
tyObject_AvlNode__HGw0Fii3rdknN9aH9aqThc3g* root;
tyObject_AvlNode__HGw0Fii3rdknN9aH9aqThc3g* deleted;
tyObject_AvlNode__HGw0Fii3rdknN9aH9aqThc3g* last;
tyObject_AvlNode__HGw0Fii3rdknN9aH9aqThc3g* freeAvlNodes;
NIM_BOOL locked;
NIM_BOOL blockChunkSizeIncrease;
NI nextChunkSize;
tyObject_AvlNode__HGw0Fii3rdknN9aH9aqThc3g bottomData;
tyObject_HeapLinks__Bw0IMvdOVqyBxxH1ZmEDeg heapLinks;
};
struct tyObject_GcStat__fGBxrB5bu5S0xC9brjmfkoQ {
NI stackScans;
NI cycleCollections;
NI maxThreshold;
NI maxStackSize;
NI maxStackCells;
NI cycleTableSize;
NI64 maxPause;
};
struct tyObject_CellSet__UY9caB79b0qIHRObBn8A4WSA {
NI counter;
NI max;
tyObject_PageDesc__j9aIB2yRpeIkPT6e1CrFY5g* head;
tyObject_PageDesc__j9aIB2yRpeIkPT6e1CrFY5g** data;
};
struct tyObject_GcHeap__t69aQjzxW7FmvOL7XpHLmyw {
tyObject_GcStack__rDlr9cRaEdNqxGR9croMEJNw stack;
NI cycleThreshold;
NI zctThreshold;
tyObject_CellSeq__jRKHLJ9a9c5ErVSJdxK4Cpgg zct;
tyObject_CellSeq__jRKHLJ9a9c5ErVSJdxK4Cpgg decStack;
tyObject_CellSeq__jRKHLJ9a9c5ErVSJdxK4Cpgg tempStack;
NI recGcLock;
tyObject_MemRegion__D0dQEAx0h5Bhgc8Q6BW2Iw region;
tyObject_GcStat__fGBxrB5bu5S0xC9brjmfkoQ stat;
tyObject_CellSet__UY9caB79b0qIHRObBn8A4WSA marked;
tyObject_CellSeq__jRKHLJ9a9c5ErVSJdxK4Cpgg additionalRoots;
NI gcThreadId;
};
typedef NU8 tySet_tyEnum_ProcessOption__aKwERgzGtdioj2ZEdjVk1A;
struct tyTuple__XOVT24GHXwqiEj5GCsEGCA {
NimStringDesc* Field0;
NI Field1;
};
N_LIB_PRIVATE N_NIMCALL(void, nimGCvisit)(void* d, NI op);
static N_NIMCALL(void, TM__SRd76hP9cMfCzdUO857UhQQ_2)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimRegisterGlobalMarker)(tyProc__T4eqaYlFJYZUv9aG9b1TV0bQ markerProc);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, copyStringRC1)(NimStringDesc* src);
static N_INLINE(void, nimGCunrefNoCycle)(void* p);
static N_INLINE(void, decRef__system_u5350)(tyObject_Cell__USbPc9alteBFOfRejw0IPYQ* c);
static N_INLINE(NI, minuspercent___system_u716)(NI x, NI y);
static N_INLINE(void, nimFrame)(TFrame* s);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u2997)(void);
static N_INLINE(void, popFrame)(void);
static N_INLINE(NIM_BOOL, ltpercent___system_u1005)(NI x, NI y);
static N_INLINE(void, rtlAddZCT__system_u5348)(tyObject_Cell__USbPc9alteBFOfRejw0IPYQ* c);
N_LIB_PRIVATE N_NOINLINE(void, addZCT__system_u5299)(tyObject_CellSeq__jRKHLJ9a9c5ErVSJdxK4Cpgg* s, tyObject_Cell__USbPc9alteBFOfRejw0IPYQ* c);
static N_INLINE(tyObject_Cell__USbPc9alteBFOfRejw0IPYQ*, usrToCell__system_u5305)(void* usr);
N_LIB_PRIVATE N_NIMCALL(void, writeFile__systemZio_u477)(NimStringDesc* filename, NimStringDesc* content);
N_LIB_PRIVATE N_NIMCALL(void, execCmdEx__pureZosproc_u1218)(NimStringDesc* command, tySet_tyEnum_ProcessOption__aKwERgzGtdioj2ZEdjVk1A options, tyObject_StringTableObj__g5rx0hEIWFWSMYZo0pFkqg* env, NimStringDesc* workingDir, NimStringDesc* input, tyTuple__XOVT24GHXwqiEj5GCsEGCA* Result);
static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a, int v, NI size);
static N_NIMCALL(void, TM__SRd76hP9cMfCzdUO857UhQQ_6)(void);
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__systemZassertions_u56)(NimStringDesc* msg);
static N_INLINE(void, initStackBottomWith)(void* locals);
N_LIB_PRIVATE N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot20atslibatssystematsiodotnim_DatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot20atslibatssystemdotnim_DatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot20atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot20atslibatsposixatsposixdotnim_DatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot20atslibatspureatstimesdotnim_DatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot20atslibatspureatstimesdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot20atslibatspureatsstreamsdotnim_DatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot20atslibatspureatsosprocdotnim_DatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
extern TNimType NTIstring__77mFvmsOLKik79ci2hXkHEg_;
STRING_LITERAL(TM__SRd76hP9cMfCzdUO857UhQQ_3, "type ArrayBuf*[N: static int, T] = object\012  buf: array[N, T]\012func maxLen(T: type): int =\012  sizeof(T) * 2\012type MyBuf[I: type] = ArrayBuf[maxLen(I), byte]\012var v: MyBuf[int]\012", 171);
STRING_LITERAL(TM__SRd76hP9cMfCzdUO857UhQQ_4, "test.nim", 8);
STRING_LITERAL(TM__SRd76hP9cMfCzdUO857UhQQ_5, "nim c -r test.nim", 17);
STRING_LITERAL(TM__SRd76hP9cMfCzdUO857UhQQ_7, "/home/runner/work/Nim/Nim/temp.nim(13, 10) `exitCode != 0` ", 59);
N_LIB_PRIVATE NimStringDesc* code__temp_u1;
extern TFrame* framePtr__system_u2564;
extern tyObject_GcHeap__t69aQjzxW7FmvOL7XpHLmyw gch__system_u5252;
N_LIB_PRIVATE NimStringDesc* ___temp_u3;
N_LIB_PRIVATE NI exitCode__temp_u4;
static N_NIMCALL(void, TM__SRd76hP9cMfCzdUO857UhQQ_2)(void) {
 nimGCvisit((void*)code__temp_u1, 0);
}
static N_INLINE(void, nimFrame)(TFrame* s) {
 {
  if (!(framePtr__system_u2564 == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s).calldepth = ((NI16) 0);
 }
 goto LA1_;
 LA3_: ;
 {
  (*s).calldepth = (NI16)((*framePtr__system_u2564).calldepth + ((NI16) 1));
 }
 LA1_: ;
 (*s).prev = framePtr__system_u2564;
 framePtr__system_u2564 = s;
 {
  if (!((*s).calldepth == ((NI16) 2000))) goto LA8_;
  callDepthLimitReached__system_u2997();
 }
 LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__system_u2564 = (*framePtr__system_u2564).prev;
}
static N_INLINE(NI, minuspercent___system_u716)(NI x, NI y) {
 NI result;
 nimfr_("-%", "/home/runner/.choosenim/toolchains/nim-1.6.20/lib/system/arithmetics.nim");
 result = (NI)0;
 result = ((NI) ((NU)((NU64)(((NU) (x))) - (NU64)(((NU) (y))))));
 popFrame();
 return result;
}
static N_INLINE(NIM_BOOL, ltpercent___system_u1005)(NI x, NI y) {
 NIM_BOOL result;
 nimfr_("<%", "/home/runner/.choosenim/toolchains/nim-1.6.20/lib/system/comparisons.nim");
 result = (NIM_BOOL)0;
 result = ((NU64)(((NU) (x))) < (NU64)(((NU) (y))));
 popFrame();
 return result;
}
static N_INLINE(void, rtlAddZCT__system_u5348)(tyObject_Cell__USbPc9alteBFOfRejw0IPYQ* c) {
 nimfr_("rtlAddZCT", "/home/runner/.choosenim/toolchains/nim-1.6.20/lib/system/gc.nim");
 addZCT__system_u5299((&gch__system_u5252.zct), c);
 popFrame();
}
static N_INLINE(void, decRef__system_u5350)(tyObject_Cell__USbPc9alteBFOfRejw0IPYQ* c) {
 nimfr_("decRef", "/home/runner/.choosenim/toolchains/nim-1.6.20/lib/system/gc.nim");
 (*c).refcount = minuspercent___system_u716((*c).refcount, ((NI) 8));
 {
  NIM_BOOL T3_;
  T3_ = (NIM_BOOL)0;
  T3_ = ltpercent___system_u1005((*c).refcount, ((NI) 8));
  if (!T3_) goto LA4_;
  rtlAddZCT__system_u5348(c);
 }
 LA4_: ;
 popFrame();
}
static N_INLINE(tyObject_Cell__USbPc9alteBFOfRejw0IPYQ*, usrToCell__system_u5305)(void* usr) {
 tyObject_Cell__USbPc9alteBFOfRejw0IPYQ* result;
 NI T1_;
 nimfr_("usrToCell", "/home/runner/.choosenim/toolchains/nim-1.6.20/lib/system/gc.nim");
 result = (tyObject_Cell__USbPc9alteBFOfRejw0IPYQ*)0;
 T1_ = (NI)0;
 T1_ = minuspercent___system_u716(((NI) (ptrdiff_t) (usr)), ((NI) 16));
 result = ((tyObject_Cell__USbPc9alteBFOfRejw0IPYQ*) (T1_));
 popFrame();
 return result;
}
static N_INLINE(void, nimGCunrefNoCycle)(void* p) {
 tyObject_Cell__USbPc9alteBFOfRejw0IPYQ* T1_;
 nimfr_("nimGCunrefNoCycle", "/home/runner/.choosenim/toolchains/nim-1.6.20/lib/system/gc.nim");
 T1_ = (tyObject_Cell__USbPc9alteBFOfRejw0IPYQ*)0;
 T1_ = usrToCell__system_u5305(p);
 decRef__system_u5350(T1_);
 popFrame();
}
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a, int v, NI size) {
 void* T1_;
 T1_ = (void*)0;
 T1_ = memset(a, v, ((size_t) (size)));
}
static N_INLINE(void, nimZeroMem)(void* p, NI size) {
 nimSetMem__systemZmemory_u7(p, ((int) 0), size);
}
static N_NIMCALL(void, TM__SRd76hP9cMfCzdUO857UhQQ_6)(void) {
 nimGCvisit((void*)___temp_u3, 0);
}
static N_INLINE(void, initStackBottomWith)(void* locals) {
 nimGC_setStackBottom(locals);
}
N_LIB_PRIVATE void PreMainInner(void) {
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot20atslibatspureatstimesdotnim_Init000();
}
 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;
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot20atslibatssystematsiodotnim_DatInit000();
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot20atslibatssystemdotnim_DatInit000();
 initStackBottomWith((void *)&inner);
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot20atslibatssystemdotnim_Init000();
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot20atslibatsposixatsposixdotnim_DatInit000();
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot20atslibatspureatstimesdotnim_DatInit000();
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot20atslibatspureatsstreamsdotnim_DatInit000();
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot20atslibatspureatsosprocdotnim_DatInit000();
 (*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) {
{
 TFrame FR_; FR_.len = 0;
 nimRegisterGlobalMarker(TM__SRd76hP9cMfCzdUO857UhQQ_2);
 nimRegisterGlobalMarker(TM__SRd76hP9cMfCzdUO857UhQQ_6);
}
{
 NimStringDesc* T1_;
 tyTuple__XOVT24GHXwqiEj5GCsEGCA T2_;
 NimStringDesc* T3_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
 T1_ = NIM_NIL;
 T1_ = code__temp_u1; code__temp_u1 = copyStringRC1(((NimStringDesc*) &TM__SRd76hP9cMfCzdUO857UhQQ_3));
 if (T1_) nimGCunrefNoCycle(T1_);
 writeFile__systemZio_u477(((NimStringDesc*) &TM__SRd76hP9cMfCzdUO857UhQQ_4), code__temp_u1);
 nimZeroMem((void*)(&T2_), sizeof(tyTuple__XOVT24GHXwqiEj5GCsEGCA));
 execCmdEx__pureZosproc_u1218(((NimStringDesc*) &TM__SRd76hP9cMfCzdUO857UhQQ_5), 10, ((tyObject_StringTableObj__g5rx0hEIWFWSMYZo0pFkqg*) NIM_NIL), ((NimStringDesc*) NIM_NIL), ((NimStringDesc*) NIM_NIL), (&T2_));
 T3_ = NIM_NIL;
 T3_ = ___temp_u3; ___temp_u3 = copyStringRC1(T2_.Field0);
 if (T3_) nimGCunrefNoCycle(T3_);
 exitCode__temp_u4 = T2_.Field1;
 {
  if (!!(!((exitCode__temp_u4 == ((NI) 0))))) goto LA6_;
  failedAssertImpl__systemZassertions_u56(((NimStringDesc*) &TM__SRd76hP9cMfCzdUO857UhQQ_7));
 }
 LA6_: ;
 popFrame();
}
}

Stats

  • Started 2024-10-30T11:37:44
  • Finished 2024-10-30T11:37:46
  • Duration 1 mins

AST

nnkStmtList.newTree(
  nnkLetSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("code"),
      newEmptyNode(),
      newLit("  type ArrayBuf*[N: static int, T] = object\n    buf: array[N, T]\n  func maxLen(T: type): int =\n    sizeof(T) * 2\n  type MyBuf[I: type] = ArrayBuf[maxLen(I), byte]\n  var v: MyBuf[int]\n  ")
    )
  ),
  nnkCall.newTree(
    newIdentNode("writeFile"),
    newLit("test.nim"),
    newIdentNode("code")
  ),
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("osproc")
    )
  ),
  nnkLetSection.newTree(
    nnkVarTuple.newTree(
      newIdentNode("_"),
      newIdentNode("exitCode"),
      newEmptyNode(),
      nnkCall.newTree(
        newIdentNode("execCmdEx"),
        newLit("nim c -r test.nim")
      )
    )
  ),
  nnkCommand.newTree(
    newIdentNode("doAssert"),
    nnkInfix.newTree(
      newIdentNode("!="),
      newIdentNode("exitCode"),
      newLit(0)
    )
  )
)
1.4.8 👎 FAIL

Output


IR

Compiled filesize 215.22 Kb (220,384 bytes)
#include "nimbase.h"
#include <string.h>
#  define nimfr_(proc, file) \
 TFrame FR_; \
 FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
#  define nimfrs_(proc, file, slots, length) \
 struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename; NI len; VarSlot s[slots];} FR_; \
 FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
#  define nimln_(n, file) \
 FR_.line = n; FR_.filename = file;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g;
typedef struct tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w;
typedef struct tyObject_GcHeap__1TRH1TZMaVZTnLNcIHuNFQ tyObject_GcHeap__1TRH1TZMaVZTnLNcIHuNFQ;
typedef struct tyObject_GcStack__7fytPA5bBsob6See21YMRA tyObject_GcStack__7fytPA5bBsob6See21YMRA;
typedef struct tyObject_MemRegion__x81NhDv59b8ercDZ9bi85jyg tyObject_MemRegion__x81NhDv59b8ercDZ9bi85jyg;
typedef struct tyObject_SmallChunk__tXn60W2f8h3jgAYdEmy5NQ tyObject_SmallChunk__tXn60W2f8h3jgAYdEmy5NQ;
typedef struct tyObject_BigChunk__Rv9c70Uhp2TytkX7eH78qEg tyObject_BigChunk__Rv9c70Uhp2TytkX7eH78qEg;
typedef struct tyObject_LLChunk__XsENErzHIZV9bhvyJx56wGw tyObject_LLChunk__XsENErzHIZV9bhvyJx56wGw;
typedef struct tyObject_IntSet__EZObFrE3NC9bIb3YMkY9crZA tyObject_IntSet__EZObFrE3NC9bIb3YMkY9crZA;
typedef struct tyObject_Trunk__W0r8S0Y3UGke6T9bIUWnnuw tyObject_Trunk__W0r8S0Y3UGke6T9bIUWnnuw;
typedef struct tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw;
typedef struct tyObject_HeapLinks__PDV1HBZ8CQSQJC9aOBFNRSg tyObject_HeapLinks__PDV1HBZ8CQSQJC9aOBFNRSg;
typedef struct tyTuple__ujsjpB2O9cjj3uDHsXbnSzg tyTuple__ujsjpB2O9cjj3uDHsXbnSzg;
typedef struct tyObject_GcStat__0RwLoVBHZPfUAcLczmfQAg tyObject_GcStat__0RwLoVBHZPfUAcLczmfQAg;
typedef struct tyObject_CellSet__jG87P0AI9aZtss9ccTYBIISQ tyObject_CellSet__jG87P0AI9aZtss9ccTYBIISQ;
typedef struct tyObject_PageDesc__fublkgIY4LG3mT51LU2WHg tyObject_PageDesc__fublkgIY4LG3mT51LU2WHg;
typedef struct tyObject_StringTableObj__V5PVrt9bIxZEeV7lfvqqtNg tyObject_StringTableObj__V5PVrt9bIxZEeV7lfvqqtNg;
typedef struct tyTuple__XOVT24GHXwqiEj5GCsEGCA tyTuple__XOVT24GHXwqiEj5GCsEGCA;
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef NU8 tyEnum_TNimKind__jIBKr1ejBgsfM33Kxw4j7A;
typedef NU8 tySet_tyEnum_TNimTypeFlag__v8QUszD1sWlSIWZz7mC4bQ;
typedef N_NIMCALL_PTR(void, tyProc__ojoeKfW4VYIm36I9cpDTQIg) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ) (void* p);
struct TNimType {
NI size;
NI align;
tyEnum_TNimKind__jIBKr1ejBgsfM33Kxw4j7A kind;
tySet_tyEnum_TNimTypeFlag__v8QUszD1sWlSIWZz7mC4bQ flags;
TNimType* base;
TNimNode* node;
void* finalizer;
tyProc__ojoeKfW4VYIm36I9cpDTQIg marker;
tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ deepcopy;
};
typedef NU8 tyEnum_TNimNodeKind__unfNsxrcATrufDZmpBq4HQ;
struct TNimNode {
tyEnum_TNimNodeKind__unfNsxrcATrufDZmpBq4HQ kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
typedef N_NIMCALL_PTR(void, tyProc__T4eqaYlFJYZUv9aG9b1TV0bQ) (void);
struct tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g {
NI refcount;
TNimType* typ;
};
struct tyObject_GcStack__7fytPA5bBsob6See21YMRA {
void* bottom;
};
struct tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w {
NI len;
NI cap;
tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g** d;
};
typedef tyObject_SmallChunk__tXn60W2f8h3jgAYdEmy5NQ* tyArray__SPr7N6UKfuF549bNPiUvSRw[256];
typedef NU32 tyArray__BHbOSqU1t9b3Gt7K2c6fQig[24];
typedef tyObject_BigChunk__Rv9c70Uhp2TytkX7eH78qEg* tyArray__N1u1nqOgmuJN9cSZrnMHgOQ[32];
typedef tyArray__N1u1nqOgmuJN9cSZrnMHgOQ tyArray__B6durA4ZCi1xjJvRtyYxMg[24];
typedef tyObject_Trunk__W0r8S0Y3UGke6T9bIUWnnuw* tyArray__lh2A89ahMmYg9bCmpVaplLbA[256];
struct tyObject_IntSet__EZObFrE3NC9bIb3YMkY9crZA {
tyArray__lh2A89ahMmYg9bCmpVaplLbA data;
};
typedef tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw* tyArray__0aOLqZchNi8nWtMTi8ND8w[2];
struct tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw {
tyArray__0aOLqZchNi8nWtMTi8ND8w link;
NI key;
NI upperBound;
NI level;
};
struct tyTuple__ujsjpB2O9cjj3uDHsXbnSzg {
tyObject_BigChunk__Rv9c70Uhp2TytkX7eH78qEg* Field0;
NI Field1;
};
typedef tyTuple__ujsjpB2O9cjj3uDHsXbnSzg tyArray__LzOv2eCDGiceMKQstCLmhw[30];
struct tyObject_HeapLinks__PDV1HBZ8CQSQJC9aOBFNRSg {
NI len;
tyArray__LzOv2eCDGiceMKQstCLmhw chunks;
tyObject_HeapLinks__PDV1HBZ8CQSQJC9aOBFNRSg* next;
};
struct tyObject_MemRegion__x81NhDv59b8ercDZ9bi85jyg {
NI minLargeObj;
NI maxLargeObj;
tyArray__SPr7N6UKfuF549bNPiUvSRw freeSmallChunks;
NU32 flBitmap;
tyArray__BHbOSqU1t9b3Gt7K2c6fQig slBitmap;
tyArray__B6durA4ZCi1xjJvRtyYxMg matrix;
tyObject_LLChunk__XsENErzHIZV9bhvyJx56wGw* llmem;
NI currMem;
NI maxMem;
NI freeMem;
NI occ;
NI lastSize;
tyObject_IntSet__EZObFrE3NC9bIb3YMkY9crZA chunkStarts;
tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw* root;
tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw* deleted;
tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw* last;
tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw* freeAvlNodes;
NIM_BOOL locked;
NIM_BOOL blockChunkSizeIncrease;
NI nextChunkSize;
tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw bottomData;
tyObject_HeapLinks__PDV1HBZ8CQSQJC9aOBFNRSg heapLinks;
};
struct tyObject_GcStat__0RwLoVBHZPfUAcLczmfQAg {
NI stackScans;
NI cycleCollections;
NI maxThreshold;
NI maxStackSize;
NI maxStackCells;
NI cycleTableSize;
NI64 maxPause;
};
struct tyObject_CellSet__jG87P0AI9aZtss9ccTYBIISQ {
NI counter;
NI max;
tyObject_PageDesc__fublkgIY4LG3mT51LU2WHg* head;
tyObject_PageDesc__fublkgIY4LG3mT51LU2WHg** data;
};
struct tyObject_GcHeap__1TRH1TZMaVZTnLNcIHuNFQ {
tyObject_GcStack__7fytPA5bBsob6See21YMRA stack;
NI cycleThreshold;
NI zctThreshold;
tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w zct;
tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w decStack;
tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w tempStack;
NI recGcLock;
tyObject_MemRegion__x81NhDv59b8ercDZ9bi85jyg region;
tyObject_GcStat__0RwLoVBHZPfUAcLczmfQAg stat;
tyObject_CellSet__jG87P0AI9aZtss9ccTYBIISQ marked;
tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w additionalRoots;
NI gcThreadId;
};
typedef NU8 tySet_tyEnum_ProcessOption__bnU6W8LhTMnT4JaSWtGlSA;
struct tyTuple__XOVT24GHXwqiEj5GCsEGCA {
NimStringDesc* Field0;
NI Field1;
};
N_LIB_PRIVATE N_NIMCALL(void, nimGCvisit)(void* d, NI op);
static N_NIMCALL(void, TM__SRd76hP9cMfCzdUO857UhQQ_2)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimRegisterGlobalMarker)(tyProc__T4eqaYlFJYZUv9aG9b1TV0bQ markerProc);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, copyStringRC1)(NimStringDesc* src);
static N_INLINE(void, nimGCunrefNoCycle)(void* p);
static N_INLINE(void, decRef__AT1eRuflKWyTTBdLjEDZbg_2system)(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* c);
static N_INLINE(NI, minuspercent___dgYAo7RfdUVVpvkfKDym8wsystem)(NI x, NI y);
static N_INLINE(void, nimFrame)(TFrame* s);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__mMRdr4sgmnykA9aWeM9aDZlw)(void);
static N_INLINE(void, popFrame)(void);
static N_INLINE(NIM_BOOL, ltpercent___hPljn3JCDQ00ua1R07X9bxQsystem)(NI x, NI y);
static N_INLINE(void, rtlAddZCT__AT1eRuflKWyTTBdLjEDZbg_3system)(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* c);
N_LIB_PRIVATE N_NOINLINE(void, addZCT__Y66tOYFjgwJ0k4aLz4bc0Q)(tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w* s, tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* c);
static N_INLINE(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g*, usrToCell__QFQqcLB3lgOdwipkv9a60xwsystem)(void* usr);
N_LIB_PRIVATE N_NIMCALL(void, writeFile__D6Pj9c29aCLEJP9beOWa08HYA)(NimStringDesc* filename, NimStringDesc* content);
N_LIB_PRIVATE N_NIMCALL(void, execCmdEx__130zQ9a9cS3YNDwoh0G9at3bw)(NimStringDesc* command, tySet_tyEnum_ProcessOption__bnU6W8LhTMnT4JaSWtGlSA options, tyObject_StringTableObj__V5PVrt9bIxZEeV7lfvqqtNg* env, NimStringDesc* workingDir, NimStringDesc* input, tyTuple__XOVT24GHXwqiEj5GCsEGCA* Result);
static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size);
static N_NIMCALL(void, TM__SRd76hP9cMfCzdUO857UhQQ_6)(void);
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);
N_LIB_PRIVATE N_NIMCALL(void, stdlib_ioDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, stdlib_posixDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, stdlib_timesDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, stdlib_timesInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, stdlib_osDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, stdlib_osInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, stdlib_streamsDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, stdlib_osprocDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
extern TNimType NTI__77mFvmsOLKik79ci2hXkHEg_;
STRING_LITERAL(TM__SRd76hP9cMfCzdUO857UhQQ_3, "type ArrayBuf*[N: static int, T] = object\012  buf: array[N, T]\012fu"
"nc maxLen(T: type): int =\012  sizeof(T) * 2\012type MyBuf[I: type] = "
"ArrayBuf[maxLen(I), byte]\012var v: MyBuf[int]\012", 171);
STRING_LITERAL(TM__SRd76hP9cMfCzdUO857UhQQ_4, "test.nim", 8);
STRING_LITERAL(TM__SRd76hP9cMfCzdUO857UhQQ_5, "nim c -r test.nim", 17);
STRING_LITERAL(TM__SRd76hP9cMfCzdUO857UhQQ_7, "/home/runner/work/Nim/Nim/temp.nim(13, 10) `exitCode != 0` ", 59);
N_LIB_PRIVATE NimStringDesc* code__oT69bA2m29a7pvQn7f2NJhvQ;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern tyObject_GcHeap__1TRH1TZMaVZTnLNcIHuNFQ gch__IcYaEuuWivYAS86vFMTS3Q;
N_LIB_PRIVATE NimStringDesc* ___FtN4iS9bLWFzC8ZqGcmDc4Q;
N_LIB_PRIVATE NI exitCode__Q2nKo9cWSVYKDoR62gUc1hw;
static N_NIMCALL(void, TM__SRd76hP9cMfCzdUO857UhQQ_2)(void) {
 nimGCvisit((void*)code__oT69bA2m29a7pvQn7f2NJhvQ, 0);
}
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;
}
static N_INLINE(NI, minuspercent___dgYAo7RfdUVVpvkfKDym8wsystem)(NI x, NI y) {
 NI result;
 nimfr_("-%", "/home/runner/.choosenim/toolchains/nim-1.4.8/lib/system/arithme"
"tics.nim");
 result = (NI)0;
 result = ((NI) ((NU)((NU64)(((NU) (x))) - (NU64)(((NU) (y))))));
 popFrame();
 return result;
}
static N_INLINE(NIM_BOOL, ltpercent___hPljn3JCDQ00ua1R07X9bxQsystem)(NI x, NI y) {
 NIM_BOOL result;
 nimfr_("<%", "/home/runner/.choosenim/toolchains/nim-1.4.8/lib/system/compari"
"sons.nim");
 result = (NIM_BOOL)0;
 result = ((NU64)(((NU) (x))) < (NU64)(((NU) (y))));
 popFrame();
 return result;
}
static N_INLINE(void, rtlAddZCT__AT1eRuflKWyTTBdLjEDZbg_3system)(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* c) {
 nimfr_("rtlAddZCT", "/home/runner/.choosenim/toolchains/nim-1.4.8/lib/system/gc.nim");
 addZCT__Y66tOYFjgwJ0k4aLz4bc0Q((&gch__IcYaEuuWivYAS86vFMTS3Q.zct), c);
 popFrame();
}
static N_INLINE(void, decRef__AT1eRuflKWyTTBdLjEDZbg_2system)(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* c) {
 nimfr_("decRef", "/home/runner/.choosenim/toolchains/nim-1.4.8/lib/system/gc.nim");
 (*c).refcount = minuspercent___dgYAo7RfdUVVpvkfKDym8wsystem((*c).refcount, ((NI) 8));
 {
  NIM_BOOL T3_;
  T3_ = (NIM_BOOL)0;
  T3_ = ltpercent___hPljn3JCDQ00ua1R07X9bxQsystem((*c).refcount, ((NI) 8));
  if (!T3_) goto LA4_;
  rtlAddZCT__AT1eRuflKWyTTBdLjEDZbg_3system(c);
 }
 LA4_: ;
 popFrame();
}
static N_INLINE(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g*, usrToCell__QFQqcLB3lgOdwipkv9a60xwsystem)(void* usr) {
 tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* result;
 NI T1_;
 nimfr_("usrToCell", "/home/runner/.choosenim/toolchains/nim-1.4.8/lib/system/gc.nim");
 result = (tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g*)0;
 T1_ = (NI)0;
 T1_ = minuspercent___dgYAo7RfdUVVpvkfKDym8wsystem(((NI) (ptrdiff_t) (usr)), ((NI) 16));
 result = ((tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g*) (T1_));
 popFrame();
 return result;
}
static N_INLINE(void, nimGCunrefNoCycle)(void* p) {
 tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* T1_;
 nimfr_("nimGCunrefNoCycle", "/home/runner/.choosenim/toolchains/nim-1.4.8/lib/system/gc.nim");
 T1_ = (tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g*)0;
 T1_ = usrToCell__QFQqcLB3lgOdwipkv9a60xwsystem(p);
 decRef__AT1eRuflKWyTTBdLjEDZbg_2system(T1_);
 popFrame();
}
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size) {
 void* T1_;
 T1_ = (void*)0;
 T1_ = memset(a, v, ((size_t) (size)));
}
static N_INLINE(void, nimZeroMem)(void* p, NI size) {
 nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory(p, ((int) 0), size);
}
static N_NIMCALL(void, TM__SRd76hP9cMfCzdUO857UhQQ_6)(void) {
 nimGCvisit((void*)___FtN4iS9bLWFzC8ZqGcmDc4Q, 0);
}
static N_INLINE(void, initStackBottomWith)(void* locals) {
 nimGC_setStackBottom(locals);
}
N_LIB_PRIVATE void PreMainInner(void) {
 stdlib_timesInit000();
 stdlib_osInit000();
}
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;
 stdlib_ioDatInit000();
 systemDatInit000();
 initStackBottomWith((void *)&inner);
 systemInit000();
 stdlib_posixDatInit000();
 stdlib_timesDatInit000();
 stdlib_osDatInit000();
 stdlib_streamsDatInit000();
 stdlib_osprocDatInit000();
 (*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) {
{
 TFrame FR_; FR_.len = 0;
 nimRegisterGlobalMarker(TM__SRd76hP9cMfCzdUO857UhQQ_2);
 nimRegisterGlobalMarker(TM__SRd76hP9cMfCzdUO857UhQQ_6);
}
{
 NimStringDesc* T1_;
 tyTuple__XOVT24GHXwqiEj5GCsEGCA T2_;
 NimStringDesc* T3_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
 T1_ = (NimStringDesc*)0;
 T1_ = code__oT69bA2m29a7pvQn7f2NJhvQ; code__oT69bA2m29a7pvQn7f2NJhvQ = copyStringRC1(((NimStringDesc*) &TM__SRd76hP9cMfCzdUO857UhQQ_3));
 if (T1_) nimGCunrefNoCycle(T1_);
 writeFile__D6Pj9c29aCLEJP9beOWa08HYA(((NimStringDesc*) &TM__SRd76hP9cMfCzdUO857UhQQ_4), code__oT69bA2m29a7pvQn7f2NJhvQ);
 nimZeroMem((void*)(&T2_), sizeof(tyTuple__XOVT24GHXwqiEj5GCsEGCA));
 execCmdEx__130zQ9a9cS3YNDwoh0G9at3bw(((NimStringDesc*) &TM__SRd76hP9cMfCzdUO857UhQQ_5), 10, ((tyObject_StringTableObj__V5PVrt9bIxZEeV7lfvqqtNg*) NIM_NIL), ((NimStringDesc*) NIM_NIL), ((NimStringDesc*) NIM_NIL), (&T2_));
 T3_ = (NimStringDesc*)0;
 T3_ = ___FtN4iS9bLWFzC8ZqGcmDc4Q; ___FtN4iS9bLWFzC8ZqGcmDc4Q = copyStringRC1(T2_.Field0);
 if (T3_) nimGCunrefNoCycle(T3_);
 exitCode__Q2nKo9cWSVYKDoR62gUc1hw = T2_.Field1;
 {
  if (!!(!((exitCode__Q2nKo9cWSVYKDoR62gUc1hw == ((NI) 0))))) goto LA6_;
  failedAssertImpl__W9cjVocn1tjhW7p7xohJj6A(((NimStringDesc*) &TM__SRd76hP9cMfCzdUO857UhQQ_7));
 }
 LA6_: ;
 popFrame();
}
}

Stats

  • Started 2024-10-30T11:37:49
  • Finished 2024-10-30T11:37:51
  • Duration 1 mins

AST

nnkStmtList.newTree(
  nnkLetSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("code"),
      newEmptyNode(),
      newLit("  type ArrayBuf*[N: static int, T] = object\n    buf: array[N, T]\n  func maxLen(T: type): int =\n    sizeof(T) * 2\n  type MyBuf[I: type] = ArrayBuf[maxLen(I), byte]\n  var v: MyBuf[int]\n  ")
    )
  ),
  nnkCall.newTree(
    newIdentNode("writeFile"),
    newLit("test.nim"),
    newIdentNode("code")
  ),
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("osproc")
    )
  ),
  nnkLetSection.newTree(
    nnkVarTuple.newTree(
      newIdentNode("_"),
      newIdentNode("exitCode"),
      newEmptyNode(),
      nnkCall.newTree(
        newIdentNode("execCmdEx"),
        newLit("nim c -r test.nim")
      )
    )
  ),
  nnkCommand.newTree(
    newIdentNode("doAssert"),
    nnkInfix.newTree(
      newIdentNode("!="),
      newIdentNode("exitCode"),
      newLit(0)
    )
  )
)
1.2.18 👎 FAIL

Output


IR

Compiled filesize 210.74 Kb (215,800 bytes)
#include "nimbase.h"
#include <string.h>
#  define nimfr_(proc, file) \
 TFrame FR_; \
 FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
#  define nimfrs_(proc, file, slots, length) \
 struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename; NI len; VarSlot s[slots];} FR_; \
 FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
#  define nimln_(n, file) \
 FR_.line = n; FR_.filename = file;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g;
typedef struct tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w;
typedef struct tyObject_GcHeap__1TRH1TZMaVZTnLNcIHuNFQ tyObject_GcHeap__1TRH1TZMaVZTnLNcIHuNFQ;
typedef struct tyObject_GcStack__7fytPA5bBsob6See21YMRA tyObject_GcStack__7fytPA5bBsob6See21YMRA;
typedef struct tyObject_MemRegion__x81NhDv59b8ercDZ9bi85jyg tyObject_MemRegion__x81NhDv59b8ercDZ9bi85jyg;
typedef struct tyObject_SmallChunk__tXn60W2f8h3jgAYdEmy5NQ tyObject_SmallChunk__tXn60W2f8h3jgAYdEmy5NQ;
typedef struct tyObject_BigChunk__Rv9c70Uhp2TytkX7eH78qEg tyObject_BigChunk__Rv9c70Uhp2TytkX7eH78qEg;
typedef struct tyObject_LLChunk__XsENErzHIZV9bhvyJx56wGw tyObject_LLChunk__XsENErzHIZV9bhvyJx56wGw;
typedef struct tyObject_IntSet__EZObFrE3NC9bIb3YMkY9crZA tyObject_IntSet__EZObFrE3NC9bIb3YMkY9crZA;
typedef struct tyObject_Trunk__W0r8S0Y3UGke6T9bIUWnnuw tyObject_Trunk__W0r8S0Y3UGke6T9bIUWnnuw;
typedef struct tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw;
typedef struct tyObject_HeapLinks__PDV1HBZ8CQSQJC9aOBFNRSg tyObject_HeapLinks__PDV1HBZ8CQSQJC9aOBFNRSg;
typedef struct tyTuple__ujsjpB2O9cjj3uDHsXbnSzg tyTuple__ujsjpB2O9cjj3uDHsXbnSzg;
typedef struct tyObject_GcStat__0RwLoVBHZPfUAcLczmfQAg tyObject_GcStat__0RwLoVBHZPfUAcLczmfQAg;
typedef struct tyObject_CellSet__jG87P0AI9aZtss9ccTYBIISQ tyObject_CellSet__jG87P0AI9aZtss9ccTYBIISQ;
typedef struct tyObject_PageDesc__fublkgIY4LG3mT51LU2WHg tyObject_PageDesc__fublkgIY4LG3mT51LU2WHg;
typedef struct tyTuple__XOVT24GHXwqiEj5GCsEGCA tyTuple__XOVT24GHXwqiEj5GCsEGCA;
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef NU8 tyEnum_TNimKind__jIBKr1ejBgsfM33Kxw4j7A;
typedef NU8 tySet_tyEnum_TNimTypeFlag__v8QUszD1sWlSIWZz7mC4bQ;
typedef N_NIMCALL_PTR(void, tyProc__ojoeKfW4VYIm36I9cpDTQIg) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ) (void* p);
struct TNimType {
NI size;
tyEnum_TNimKind__jIBKr1ejBgsfM33Kxw4j7A kind;
tySet_tyEnum_TNimTypeFlag__v8QUszD1sWlSIWZz7mC4bQ flags;
TNimType* base;
TNimNode* node;
void* finalizer;
tyProc__ojoeKfW4VYIm36I9cpDTQIg marker;
tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ deepcopy;
};
typedef NU8 tyEnum_TNimNodeKind__unfNsxrcATrufDZmpBq4HQ;
struct TNimNode {
tyEnum_TNimNodeKind__unfNsxrcATrufDZmpBq4HQ kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
typedef N_NIMCALL_PTR(void, tyProc__T4eqaYlFJYZUv9aG9b1TV0bQ) (void);
struct tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g {
NI refcount;
TNimType* typ;
};
struct tyObject_GcStack__7fytPA5bBsob6See21YMRA {
void* bottom;
};
struct tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w {
NI len;
NI cap;
tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g** d;
};
typedef tyObject_SmallChunk__tXn60W2f8h3jgAYdEmy5NQ* tyArray__SiRwrEKZdLgxqz9a9aoVBglg[512];
typedef NU32 tyArray__BHbOSqU1t9b3Gt7K2c6fQig[24];
typedef tyObject_BigChunk__Rv9c70Uhp2TytkX7eH78qEg* tyArray__N1u1nqOgmuJN9cSZrnMHgOQ[32];
typedef tyArray__N1u1nqOgmuJN9cSZrnMHgOQ tyArray__B6durA4ZCi1xjJvRtyYxMg[24];
typedef tyObject_Trunk__W0r8S0Y3UGke6T9bIUWnnuw* tyArray__lh2A89ahMmYg9bCmpVaplLbA[256];
struct tyObject_IntSet__EZObFrE3NC9bIb3YMkY9crZA {
tyArray__lh2A89ahMmYg9bCmpVaplLbA data;
};
typedef tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw* tyArray__0aOLqZchNi8nWtMTi8ND8w[2];
struct tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw {
tyArray__0aOLqZchNi8nWtMTi8ND8w link;
NI key;
NI upperBound;
NI level;
};
struct tyTuple__ujsjpB2O9cjj3uDHsXbnSzg {
tyObject_BigChunk__Rv9c70Uhp2TytkX7eH78qEg* Field0;
NI Field1;
};
typedef tyTuple__ujsjpB2O9cjj3uDHsXbnSzg tyArray__LzOv2eCDGiceMKQstCLmhw[30];
struct tyObject_HeapLinks__PDV1HBZ8CQSQJC9aOBFNRSg {
NI len;
tyArray__LzOv2eCDGiceMKQstCLmhw chunks;
tyObject_HeapLinks__PDV1HBZ8CQSQJC9aOBFNRSg* next;
};
struct tyObject_MemRegion__x81NhDv59b8ercDZ9bi85jyg {
NI minLargeObj;
NI maxLargeObj;
tyArray__SiRwrEKZdLgxqz9a9aoVBglg freeSmallChunks;
NU32 flBitmap;
tyArray__BHbOSqU1t9b3Gt7K2c6fQig slBitmap;
tyArray__B6durA4ZCi1xjJvRtyYxMg matrix;
tyObject_LLChunk__XsENErzHIZV9bhvyJx56wGw* llmem;
NI currMem;
NI maxMem;
NI freeMem;
NI occ;
NI lastSize;
tyObject_IntSet__EZObFrE3NC9bIb3YMkY9crZA chunkStarts;
tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw* root;
tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw* deleted;
tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw* last;
tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw* freeAvlNodes;
NIM_BOOL locked;
NIM_BOOL blockChunkSizeIncrease;
NI nextChunkSize;
tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw bottomData;
tyObject_HeapLinks__PDV1HBZ8CQSQJC9aOBFNRSg heapLinks;
};
struct tyObject_GcStat__0RwLoVBHZPfUAcLczmfQAg {
NI stackScans;
NI cycleCollections;
NI maxThreshold;
NI maxStackSize;
NI maxStackCells;
NI cycleTableSize;
NI64 maxPause;
};
struct tyObject_CellSet__jG87P0AI9aZtss9ccTYBIISQ {
NI counter;
NI max;
tyObject_PageDesc__fublkgIY4LG3mT51LU2WHg* head;
tyObject_PageDesc__fublkgIY4LG3mT51LU2WHg** data;
};
struct tyObject_GcHeap__1TRH1TZMaVZTnLNcIHuNFQ {
tyObject_GcStack__7fytPA5bBsob6See21YMRA stack;
NI cycleThreshold;
NI zctThreshold;
tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w zct;
tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w decStack;
tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w tempStack;
NI recGcLock;
tyObject_MemRegion__x81NhDv59b8ercDZ9bi85jyg region;
tyObject_GcStat__0RwLoVBHZPfUAcLczmfQAg stat;
tyObject_CellSet__jG87P0AI9aZtss9ccTYBIISQ marked;
tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w additionalRoots;
NI gcThreadId;
};
typedef NU8 tySet_tyEnum_ProcessOption__bnU6W8LhTMnT4JaSWtGlSA;
struct tyTuple__XOVT24GHXwqiEj5GCsEGCA {
NimStringDesc* Field0;
NI Field1;
};
N_LIB_PRIVATE N_NIMCALL(void, nimGCvisit)(void* d, NI op);
static N_NIMCALL(void, TM__SRd76hP9cMfCzdUO857UhQQ_2)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimRegisterGlobalMarker)(tyProc__T4eqaYlFJYZUv9aG9b1TV0bQ markerProc);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, copyStringRC1)(NimStringDesc* src);
static N_INLINE(void, nimGCunrefNoCycle)(void* p);
static N_INLINE(void, decRef__AT1eRuflKWyTTBdLjEDZbg_2system)(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* c);
static N_INLINE(NI, minuspercent___dgYAo7RfdUVVpvkfKDym8wsystem)(NI x, NI y);
static N_INLINE(void, nimFrame)(TFrame* s);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__mMRdr4sgmnykA9aWeM9aDZlw)(void);
static N_INLINE(void, popFrame)(void);
static N_INLINE(NIM_BOOL, ltpercent___hPljn3JCDQ00ua1R07X9bxQsystem)(NI x, NI y);
static N_INLINE(void, rtlAddZCT__AT1eRuflKWyTTBdLjEDZbg_3system)(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* c);
N_LIB_PRIVATE N_NOINLINE(void, addZCT__Y66tOYFjgwJ0k4aLz4bc0Q)(tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w* s, tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* c);
static N_INLINE(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g*, usrToCell__QFQqcLB3lgOdwipkv9a60xwsystem)(void* usr);
N_LIB_PRIVATE N_NIMCALL(void, writeFile__D6Pj9c29aCLEJP9beOWa08HYA)(NimStringDesc* filename, NimStringDesc* content);
N_LIB_PRIVATE N_NIMCALL(void, execCmdEx__9cTpvDl4v9c9c9aFgpXBZMyDDA)(NimStringDesc* command, tySet_tyEnum_ProcessOption__bnU6W8LhTMnT4JaSWtGlSA options, tyTuple__XOVT24GHXwqiEj5GCsEGCA* Result);
static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size);
static N_NIMCALL(void, TM__SRd76hP9cMfCzdUO857UhQQ_6)(void);
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);
N_LIB_PRIVATE N_NIMCALL(void, stdlib_ioDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, stdlib_posixDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, stdlib_timesDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, stdlib_timesInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, stdlib_osDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, stdlib_osInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, stdlib_streamsDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, stdlib_osprocDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
extern TNimType NTI__77mFvmsOLKik79ci2hXkHEg_;
STRING_LITERAL(TM__SRd76hP9cMfCzdUO857UhQQ_3, "type ArrayBuf*[N: static int, T] = object\012  buf: array[N, T]\012fu"
"nc maxLen(T: type): int =\012  sizeof(T) * 2\012type MyBuf[I: type] = "
"ArrayBuf[maxLen(I), byte]\012var v: MyBuf[int]\012", 171);
STRING_LITERAL(TM__SRd76hP9cMfCzdUO857UhQQ_4, "test.nim", 8);
STRING_LITERAL(TM__SRd76hP9cMfCzdUO857UhQQ_5, "nim c -r test.nim", 17);
STRING_LITERAL(TM__SRd76hP9cMfCzdUO857UhQQ_7, "/home/runner/work/Nim/Nim/temp.nim(13, 10) `exitCode != 0` ", 59);
N_LIB_PRIVATE NimStringDesc* code__oT69bA2m29a7pvQn7f2NJhvQ;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern tyObject_GcHeap__1TRH1TZMaVZTnLNcIHuNFQ gch__IcYaEuuWivYAS86vFMTS3Q;
N_LIB_PRIVATE NimStringDesc* ___FtN4iS9bLWFzC8ZqGcmDc4Q;
N_LIB_PRIVATE NI exitCode__Q2nKo9cWSVYKDoR62gUc1hw;
static N_NIMCALL(void, TM__SRd76hP9cMfCzdUO857UhQQ_2)(void) {
 nimGCvisit((void*)code__oT69bA2m29a7pvQn7f2NJhvQ, 0);
}
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;
}
static N_INLINE(NI, minuspercent___dgYAo7RfdUVVpvkfKDym8wsystem)(NI x, NI y) {
 NI result;
 nimfr_("-%", "/home/runner/.choosenim/toolchains/nim-1.2.18/lib/system/arithm"
"etics.nim");
 result = (NI)0;
 result = ((NI) ((NU)((NU64)(((NU) (x))) - (NU64)(((NU) (y))))));
 popFrame();
 return result;
}
static N_INLINE(NIM_BOOL, ltpercent___hPljn3JCDQ00ua1R07X9bxQsystem)(NI x, NI y) {
 NIM_BOOL result;
 nimfr_("<%", "/home/runner/.choosenim/toolchains/nim-1.2.18/lib/system/compar"
"isons.nim");
 result = (NIM_BOOL)0;
 result = ((NU64)(((NU) (x))) < (NU64)(((NU) (y))));
 popFrame();
 return result;
}
static N_INLINE(void, rtlAddZCT__AT1eRuflKWyTTBdLjEDZbg_3system)(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* c) {
 nimfr_("rtlAddZCT", "/home/runner/.choosenim/toolchains/nim-1.2.18/lib/system/gc.nim");
 addZCT__Y66tOYFjgwJ0k4aLz4bc0Q((&gch__IcYaEuuWivYAS86vFMTS3Q.zct), c);
 popFrame();
}
static N_INLINE(void, decRef__AT1eRuflKWyTTBdLjEDZbg_2system)(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* c) {
 nimfr_("decRef", "/home/runner/.choosenim/toolchains/nim-1.2.18/lib/system/gc.nim");
 (*c).refcount = minuspercent___dgYAo7RfdUVVpvkfKDym8wsystem((*c).refcount, ((NI) 8));
 {
  NIM_BOOL T3_;
  T3_ = (NIM_BOOL)0;
  T3_ = ltpercent___hPljn3JCDQ00ua1R07X9bxQsystem((*c).refcount, ((NI) 8));
  if (!T3_) goto LA4_;
  rtlAddZCT__AT1eRuflKWyTTBdLjEDZbg_3system(c);
 }
 LA4_: ;
 popFrame();
}
static N_INLINE(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g*, usrToCell__QFQqcLB3lgOdwipkv9a60xwsystem)(void* usr) {
 tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* result;
 NI T1_;
 nimfr_("usrToCell", "/home/runner/.choosenim/toolchains/nim-1.2.18/lib/system/gc.nim");
 result = (tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g*)0;
 T1_ = (NI)0;
 T1_ = minuspercent___dgYAo7RfdUVVpvkfKDym8wsystem(((NI) (ptrdiff_t) (usr)), ((NI) 16));
 result = ((tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g*) (T1_));
 popFrame();
 return result;
}
static N_INLINE(void, nimGCunrefNoCycle)(void* p) {
 tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* T1_;
 nimfr_("nimGCunrefNoCycle", "/home/runner/.choosenim/toolchains/nim-1.2.18/lib/system/gc.nim");
 T1_ = (tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g*)0;
 T1_ = usrToCell__QFQqcLB3lgOdwipkv9a60xwsystem(p);
 decRef__AT1eRuflKWyTTBdLjEDZbg_2system(T1_);
 popFrame();
}
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size) {
 void* T1_;
 T1_ = (void*)0;
 T1_ = memset(a, v, ((size_t) (size)));
}
static N_INLINE(void, nimZeroMem)(void* p, NI size) {
 nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory(p, ((int) 0), size);
}
static N_NIMCALL(void, TM__SRd76hP9cMfCzdUO857UhQQ_6)(void) {
 nimGCvisit((void*)___FtN4iS9bLWFzC8ZqGcmDc4Q, 0);
}
static N_INLINE(void, initStackBottomWith)(void* locals) {
 nimGC_setStackBottom(locals);
}
N_LIB_PRIVATE void PreMainInner(void) {
 stdlib_timesInit000();
 stdlib_osInit000();
}
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;
 stdlib_ioDatInit000();
 systemDatInit000();
 initStackBottomWith((void *)&inner);
 systemInit000();
 stdlib_posixDatInit000();
 stdlib_timesDatInit000();
 stdlib_osDatInit000();
 stdlib_streamsDatInit000();
 stdlib_osprocDatInit000();
 (*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) {
{
 TFrame FR_; FR_.len = 0;
 nimRegisterGlobalMarker(TM__SRd76hP9cMfCzdUO857UhQQ_2);
 nimRegisterGlobalMarker(TM__SRd76hP9cMfCzdUO857UhQQ_6);
}
{
 NimStringDesc* T1_;
 tyTuple__XOVT24GHXwqiEj5GCsEGCA T2_;
 NimStringDesc* T3_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
 T1_ = NIM_NIL;
 T1_ = code__oT69bA2m29a7pvQn7f2NJhvQ; code__oT69bA2m29a7pvQn7f2NJhvQ = copyStringRC1(((NimStringDesc*) &TM__SRd76hP9cMfCzdUO857UhQQ_3));
 if (T1_) nimGCunrefNoCycle(T1_);
 writeFile__D6Pj9c29aCLEJP9beOWa08HYA(((NimStringDesc*) &TM__SRd76hP9cMfCzdUO857UhQQ_4), code__oT69bA2m29a7pvQn7f2NJhvQ);
 nimZeroMem((void*)(&T2_), sizeof(tyTuple__XOVT24GHXwqiEj5GCsEGCA));
 execCmdEx__9cTpvDl4v9c9c9aFgpXBZMyDDA(((NimStringDesc*) &TM__SRd76hP9cMfCzdUO857UhQQ_5), 10, (&T2_));
 T3_ = NIM_NIL;
 T3_ = ___FtN4iS9bLWFzC8ZqGcmDc4Q; ___FtN4iS9bLWFzC8ZqGcmDc4Q = copyStringRC1(T2_.Field0);
 if (T3_) nimGCunrefNoCycle(T3_);
 exitCode__Q2nKo9cWSVYKDoR62gUc1hw = T2_.Field1;
 {
  if (!!(!((exitCode__Q2nKo9cWSVYKDoR62gUc1hw == ((NI) 0))))) goto LA6_;
  failedAssertImpl__W9cjVocn1tjhW7p7xohJj6A(((NimStringDesc*) &TM__SRd76hP9cMfCzdUO857UhQQ_7));
 }
 LA6_: ;
 popFrame();
}
}

Stats

  • Started 2024-10-30T11:37:54
  • Finished 2024-10-30T11:37:55
  • Duration 1 mins

AST

nnkStmtList.newTree(
  nnkLetSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("code"),
      newEmptyNode(),
      newLit("  type ArrayBuf*[N: static int, T] = object\n    buf: array[N, T]\n  func maxLen(T: type): int =\n    sizeof(T) * 2\n  type MyBuf[I: type] = ArrayBuf[maxLen(I), byte]\n  var v: MyBuf[int]\n  ")
    )
  ),
  nnkCall.newTree(
    newIdentNode("writeFile"),
    newLit("test.nim"),
    newIdentNode("code")
  ),
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("osproc")
    )
  ),
  nnkLetSection.newTree(
    nnkVarTuple.newTree(
      newIdentNode("_"),
      newIdentNode("exitCode"),
      newEmptyNode(),
      nnkCall.newTree(
        newIdentNode("execCmdEx"),
        newLit("nim c -r test.nim")
      )
    )
  ),
  nnkCommand.newTree(
    newIdentNode("doAssert"),
    nnkInfix.newTree(
      newIdentNode("!="),
      newIdentNode("exitCode"),
      newLit(0)
    )
  )
)
1.0.10 👎 FAIL

Output


IR

Compiled filesize 197.78 Kb (202,528 bytes)
#include "nimbase.h"
#include <string.h>
#  define nimfr_(proc, file) \
 TFrame FR_; \
 FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
#  define nimfrs_(proc, file, slots, length) \
 struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename; NI len; VarSlot s[slots];} FR_; \
 FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
#  define nimln_(n, file) \
 FR_.line = n; FR_.filename = file;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g;
typedef struct tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w;
typedef struct tyObject_GcHeap__1TRH1TZMaVZTnLNcIHuNFQ tyObject_GcHeap__1TRH1TZMaVZTnLNcIHuNFQ;
typedef struct tyObject_GcStack__7fytPA5bBsob6See21YMRA tyObject_GcStack__7fytPA5bBsob6See21YMRA;
typedef struct tyObject_MemRegion__x81NhDv59b8ercDZ9bi85jyg tyObject_MemRegion__x81NhDv59b8ercDZ9bi85jyg;
typedef struct tyObject_SmallChunk__tXn60W2f8h3jgAYdEmy5NQ tyObject_SmallChunk__tXn60W2f8h3jgAYdEmy5NQ;
typedef struct tyObject_BigChunk__Rv9c70Uhp2TytkX7eH78qEg tyObject_BigChunk__Rv9c70Uhp2TytkX7eH78qEg;
typedef struct tyObject_LLChunk__XsENErzHIZV9bhvyJx56wGw tyObject_LLChunk__XsENErzHIZV9bhvyJx56wGw;
typedef struct tyObject_IntSet__EZObFrE3NC9bIb3YMkY9crZA tyObject_IntSet__EZObFrE3NC9bIb3YMkY9crZA;
typedef struct tyObject_Trunk__W0r8S0Y3UGke6T9bIUWnnuw tyObject_Trunk__W0r8S0Y3UGke6T9bIUWnnuw;
typedef struct tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw;
typedef struct tyObject_HeapLinks__PDV1HBZ8CQSQJC9aOBFNRSg tyObject_HeapLinks__PDV1HBZ8CQSQJC9aOBFNRSg;
typedef struct tyTuple__ujsjpB2O9cjj3uDHsXbnSzg tyTuple__ujsjpB2O9cjj3uDHsXbnSzg;
typedef struct tyObject_GcStat__0RwLoVBHZPfUAcLczmfQAg tyObject_GcStat__0RwLoVBHZPfUAcLczmfQAg;
typedef struct tyObject_CellSet__jG87P0AI9aZtss9ccTYBIISQ tyObject_CellSet__jG87P0AI9aZtss9ccTYBIISQ;
typedef struct tyObject_PageDesc__fublkgIY4LG3mT51LU2WHg tyObject_PageDesc__fublkgIY4LG3mT51LU2WHg;
typedef struct tyTuple__XOVT24GHXwqiEj5GCsEGCA tyTuple__XOVT24GHXwqiEj5GCsEGCA;
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef NU8 tyEnum_TNimKind__jIBKr1ejBgsfM33Kxw4j7A;
typedef NU8 tySet_tyEnum_TNimTypeFlag__v8QUszD1sWlSIWZz7mC4bQ;
typedef N_NIMCALL_PTR(void, tyProc__ojoeKfW4VYIm36I9cpDTQIg) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ) (void* p);
struct TNimType {
NI size;
tyEnum_TNimKind__jIBKr1ejBgsfM33Kxw4j7A kind;
tySet_tyEnum_TNimTypeFlag__v8QUszD1sWlSIWZz7mC4bQ flags;
TNimType* base;
TNimNode* node;
void* finalizer;
tyProc__ojoeKfW4VYIm36I9cpDTQIg marker;
tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ deepcopy;
};
typedef NU8 tyEnum_TNimNodeKind__unfNsxrcATrufDZmpBq4HQ;
struct TNimNode {
tyEnum_TNimNodeKind__unfNsxrcATrufDZmpBq4HQ kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
typedef N_NIMCALL_PTR(void, tyProc__T4eqaYlFJYZUv9aG9b1TV0bQ) (void);
struct tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g {
NI refcount;
TNimType* typ;
};
struct tyObject_GcStack__7fytPA5bBsob6See21YMRA {
void* bottom;
};
struct tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w {
NI len;
NI cap;
tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g** d;
};
typedef tyObject_SmallChunk__tXn60W2f8h3jgAYdEmy5NQ* tyArray__SiRwrEKZdLgxqz9a9aoVBglg[512];
typedef NU32 tyArray__BHbOSqU1t9b3Gt7K2c6fQig[24];
typedef tyObject_BigChunk__Rv9c70Uhp2TytkX7eH78qEg* tyArray__N1u1nqOgmuJN9cSZrnMHgOQ[32];
typedef tyArray__N1u1nqOgmuJN9cSZrnMHgOQ tyArray__B6durA4ZCi1xjJvRtyYxMg[24];
typedef tyObject_Trunk__W0r8S0Y3UGke6T9bIUWnnuw* tyArray__lh2A89ahMmYg9bCmpVaplLbA[256];
struct tyObject_IntSet__EZObFrE3NC9bIb3YMkY9crZA {
tyArray__lh2A89ahMmYg9bCmpVaplLbA data;
};
typedef tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw* tyArray__0aOLqZchNi8nWtMTi8ND8w[2];
struct tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw {
tyArray__0aOLqZchNi8nWtMTi8ND8w link;
NI key;
NI upperBound;
NI level;
};
struct tyTuple__ujsjpB2O9cjj3uDHsXbnSzg {
tyObject_BigChunk__Rv9c70Uhp2TytkX7eH78qEg* Field0;
NI Field1;
};
typedef tyTuple__ujsjpB2O9cjj3uDHsXbnSzg tyArray__LzOv2eCDGiceMKQstCLmhw[30];
struct tyObject_HeapLinks__PDV1HBZ8CQSQJC9aOBFNRSg {
NI len;
tyArray__LzOv2eCDGiceMKQstCLmhw chunks;
tyObject_HeapLinks__PDV1HBZ8CQSQJC9aOBFNRSg* next;
};
struct tyObject_MemRegion__x81NhDv59b8ercDZ9bi85jyg {
NI minLargeObj;
NI maxLargeObj;
tyArray__SiRwrEKZdLgxqz9a9aoVBglg freeSmallChunks;
NU32 flBitmap;
tyArray__BHbOSqU1t9b3Gt7K2c6fQig slBitmap;
tyArray__B6durA4ZCi1xjJvRtyYxMg matrix;
tyObject_LLChunk__XsENErzHIZV9bhvyJx56wGw* llmem;
NI currMem;
NI maxMem;
NI freeMem;
NI occ;
NI lastSize;
tyObject_IntSet__EZObFrE3NC9bIb3YMkY9crZA chunkStarts;
tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw* root;
tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw* deleted;
tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw* last;
tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw* freeAvlNodes;
NIM_BOOL locked;
NIM_BOOL blockChunkSizeIncrease;
NI nextChunkSize;
tyObject_AvlNode__IaqjtwKhxLEpvDS9bct9blEw bottomData;
tyObject_HeapLinks__PDV1HBZ8CQSQJC9aOBFNRSg heapLinks;
};
struct tyObject_GcStat__0RwLoVBHZPfUAcLczmfQAg {
NI stackScans;
NI cycleCollections;
NI maxThreshold;
NI maxStackSize;
NI maxStackCells;
NI cycleTableSize;
NI64 maxPause;
};
struct tyObject_CellSet__jG87P0AI9aZtss9ccTYBIISQ {
NI counter;
NI max;
tyObject_PageDesc__fublkgIY4LG3mT51LU2WHg* head;
tyObject_PageDesc__fublkgIY4LG3mT51LU2WHg** data;
};
struct tyObject_GcHeap__1TRH1TZMaVZTnLNcIHuNFQ {
tyObject_GcStack__7fytPA5bBsob6See21YMRA stack;
NI cycleThreshold;
NI zctThreshold;
tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w zct;
tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w decStack;
tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w tempStack;
NI recGcLock;
tyObject_MemRegion__x81NhDv59b8ercDZ9bi85jyg region;
tyObject_GcStat__0RwLoVBHZPfUAcLczmfQAg stat;
tyObject_CellSet__jG87P0AI9aZtss9ccTYBIISQ marked;
tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w additionalRoots;
NI gcThreadId;
};
typedef NU8 tySet_tyEnum_ProcessOption__bnU6W8LhTMnT4JaSWtGlSA;
struct tyTuple__XOVT24GHXwqiEj5GCsEGCA {
NimStringDesc* Field0;
NI Field1;
};
N_NIMCALL(void, nimGCvisit)(void* d, NI op);
static N_NIMCALL(void, TM__SRd76hP9cMfCzdUO857UhQQ_2)(void);
N_NIMCALL(void, nimRegisterGlobalMarker)(tyProc__T4eqaYlFJYZUv9aG9b1TV0bQ markerProc);
N_NIMCALL(NimStringDesc*, copyStringRC1)(NimStringDesc* src);
static N_INLINE(void, nimGCunrefNoCycle)(void* p);
static N_INLINE(void, decRef__AT1eRuflKWyTTBdLjEDZbg_2system)(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* c);
static N_INLINE(void, rtlAddZCT__AT1eRuflKWyTTBdLjEDZbg_3system)(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* c);
N_LIB_PRIVATE N_NOINLINE(void, addZCT__Y66tOYFjgwJ0k4aLz4bc0Q)(tyObject_CellSeq__Axo1XVm9aaQueTOldv8le5w* s, tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* c);
static N_INLINE(void, nimFrame)(TFrame* s);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__mMRdr4sgmnykA9aWeM9aDZlw)(void);
static N_INLINE(void, popFrame)(void);
static N_INLINE(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g*, usrToCell__QFQqcLB3lgOdwipkv9a60xwsystem)(void* usr);
N_LIB_PRIVATE N_NIMCALL(void, writeFile__D6Pj9c29aCLEJP9beOWa08HYA)(NimStringDesc* filename, NimStringDesc* content);
N_LIB_PRIVATE N_NIMCALL(void, execCmdEx__9cTpvDl4v9c9c9aFgpXBZMyDDA)(NimStringDesc* command, tySet_tyEnum_ProcessOption__bnU6W8LhTMnT4JaSWtGlSA options, tyTuple__XOVT24GHXwqiEj5GCsEGCA* Result);
static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size);
static N_NIMCALL(void, TM__SRd76hP9cMfCzdUO857UhQQ_6)(void);
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__W9cjVocn1tjhW7p7xohJj6A)(NimStringDesc* msg);
static N_INLINE(void, initStackBottomWith)(void* locals);
N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom);
N_LIB_PRIVATE N_NIMCALL(void, stdlib_ioDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, stdlib_posixDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, stdlib_timesDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, stdlib_timesInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, stdlib_osDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, stdlib_osInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, stdlib_streamsDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, stdlib_osprocDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
NimStringDesc* code__oT69bA2m29a7pvQn7f2NJhvQ;
extern TNimType NTI__77mFvmsOLKik79ci2hXkHEg_;
extern tyObject_GcHeap__1TRH1TZMaVZTnLNcIHuNFQ gch__IcYaEuuWivYAS86vFMTS3Q;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
NimStringDesc* ___FtN4iS9bLWFzC8ZqGcmDc4Q;
NI exitCode__Q2nKo9cWSVYKDoR62gUc1hw;
STRING_LITERAL(TM__SRd76hP9cMfCzdUO857UhQQ_3, "type ArrayBuf*[N: static int, T] = object\012  buf: array[N, T]\012fu"
"nc maxLen(T: type): int =\012  sizeof(T) * 2\012type MyBuf[I: type] = "
"ArrayBuf[maxLen(I), byte]\012var v: MyBuf[int]\012", 171);
STRING_LITERAL(TM__SRd76hP9cMfCzdUO857UhQQ_4, "test.nim", 8);
STRING_LITERAL(TM__SRd76hP9cMfCzdUO857UhQQ_5, "nim c -r test.nim", 17);
STRING_LITERAL(TM__SRd76hP9cMfCzdUO857UhQQ_7, "/home/runner/work/Nim/Nim/temp.nim(13, 10) `exitCode != 0` ", 59);
static N_NIMCALL(void, TM__SRd76hP9cMfCzdUO857UhQQ_2)(void) {
 nimGCvisit((void*)code__oT69bA2m29a7pvQn7f2NJhvQ, 0);
}
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;
}
static N_INLINE(void, rtlAddZCT__AT1eRuflKWyTTBdLjEDZbg_3system)(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* c) {	nimfr_("rtlAddZCT", "/home/runner/.choosenim/toolchains/nim-1.0.10/lib/system/gc.nim");
 addZCT__Y66tOYFjgwJ0k4aLz4bc0Q((&gch__IcYaEuuWivYAS86vFMTS3Q.zct), c);
 popFrame();
}
static N_INLINE(void, decRef__AT1eRuflKWyTTBdLjEDZbg_2system)(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* c) {	nimfr_("decRef", "/home/runner/.choosenim/toolchains/nim-1.0.10/lib/system/gc.nim");
 (*c).refcount = (NI)((NU64)((*c).refcount) - (NU64)(((NI) 8)));
 {
  if (!((NU64)((*c).refcount) < (NU64)(((NI) 8)))) goto LA3_;
  rtlAddZCT__AT1eRuflKWyTTBdLjEDZbg_3system(c);
 }
 LA3_: ;
 popFrame();
}
static N_INLINE(tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g*, usrToCell__QFQqcLB3lgOdwipkv9a60xwsystem)(void* usr) {	tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* result;
 nimfr_("usrToCell", "/home/runner/.choosenim/toolchains/nim-1.0.10/lib/system/gc.nim");
 result = (tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g*)0;
 result = ((tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g*) ((NI)((NU64)(((NI) (ptrdiff_t) (usr))) - (NU64)(((NI) 16)))));
 popFrame();
 return result;
}
static N_INLINE(void, nimGCunrefNoCycle)(void* p) {	tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g* T1_;
 nimfr_("nimGCunrefNoCycle", "/home/runner/.choosenim/toolchains/nim-1.0.10/lib/system/gc.nim");
 T1_ = (tyObject_Cell__1zcF9cV8XIAtbN8h5HRUB8g*)0;
 T1_ = usrToCell__QFQqcLB3lgOdwipkv9a60xwsystem(p);
 decRef__AT1eRuflKWyTTBdLjEDZbg_2system(T1_);
 popFrame();
}
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size) {	void* T1_;
 T1_ = (void*)0;
 T1_ = memset(a, v, ((size_t) (size)));
}
static N_INLINE(void, nimZeroMem)(void* p, NI size) {	nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory(p, ((int) 0), size);
}
static N_NIMCALL(void, TM__SRd76hP9cMfCzdUO857UhQQ_6)(void) {
 nimGCvisit((void*)___FtN4iS9bLWFzC8ZqGcmDc4Q, 0);
}
static N_INLINE(void, initStackBottomWith)(void* locals) {	nimGC_setStackBottom(locals);
}
void PreMainInner(void) {
 stdlib_timesInit000();
 stdlib_osInit000();
}
int cmdCount;
char** cmdLine;
char** gEnv;
void PreMain(void) {
 void (*volatile inner)(void);
 inner = PreMainInner;
 stdlib_ioDatInit000();
 systemDatInit000();
 initStackBottomWith((void *)&inner);
 systemInit000();
 stdlib_posixDatInit000();
 stdlib_timesDatInit000();
 stdlib_osDatInit000();
 stdlib_streamsDatInit000();
 stdlib_osprocDatInit000();
 (*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) {
{
 NimStringDesc* T1_;
 tyTuple__XOVT24GHXwqiEj5GCsEGCA T2_;
 NimStringDesc* T3_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
 nimRegisterGlobalMarker(TM__SRd76hP9cMfCzdUO857UhQQ_2);
 nimRegisterGlobalMarker(TM__SRd76hP9cMfCzdUO857UhQQ_6);
 T1_ = (NimStringDesc*)0;
 T1_ = code__oT69bA2m29a7pvQn7f2NJhvQ; code__oT69bA2m29a7pvQn7f2NJhvQ = copyStringRC1(((NimStringDesc*) &TM__SRd76hP9cMfCzdUO857UhQQ_3));
 if (T1_) nimGCunrefNoCycle(T1_);
 writeFile__D6Pj9c29aCLEJP9beOWa08HYA(((NimStringDesc*) &TM__SRd76hP9cMfCzdUO857UhQQ_4), code__oT69bA2m29a7pvQn7f2NJhvQ);
 nimZeroMem((void*)(&T2_), sizeof(tyTuple__XOVT24GHXwqiEj5GCsEGCA));
 execCmdEx__9cTpvDl4v9c9c9aFgpXBZMyDDA(((NimStringDesc*) &TM__SRd76hP9cMfCzdUO857UhQQ_5), 10, (&T2_));
 T3_ = (NimStringDesc*)0;
 T3_ = ___FtN4iS9bLWFzC8ZqGcmDc4Q; ___FtN4iS9bLWFzC8ZqGcmDc4Q = copyStringRC1(T2_.Field0);
 if (T3_) nimGCunrefNoCycle(T3_);
 exitCode__Q2nKo9cWSVYKDoR62gUc1hw = T2_.Field1;
 {
  if (!!(!((exitCode__Q2nKo9cWSVYKDoR62gUc1hw == ((NI) 0))))) goto LA6_;
  failedAssertImpl__W9cjVocn1tjhW7p7xohJj6A(((NimStringDesc*) &TM__SRd76hP9cMfCzdUO857UhQQ_7));
 }
 LA6_: ;
 popFrame();
}
}

Stats

  • Started 2024-10-30T11:37:58
  • Finished 2024-10-30T11:37:59
  • Duration 1 mins

AST

nnkStmtList.newTree(
  nnkLetSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("code"),
      newEmptyNode(),
      newLit("  type ArrayBuf*[N: static int, T] = object\n    buf: array[N, T]\n  func maxLen(T: type): int =\n    sizeof(T) * 2\n  type MyBuf[I: type] = ArrayBuf[maxLen(I), byte]\n  var v: MyBuf[int]\n  ")
    )
  ),
  nnkCall.newTree(
    newIdentNode("writeFile"),
    newLit("test.nim"),
    newIdentNode("code")
  ),
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("osproc")
    )
  ),
  nnkLetSection.newTree(
    nnkVarTuple.newTree(
      newIdentNode("_"),
      newIdentNode("exitCode"),
      newEmptyNode(),
      nnkCall.newTree(
        newIdentNode("execCmdEx"),
        newLit("nim c -r test.nim")
      )
    )
  ),
  nnkCommand.newTree(
    newIdentNode("doAssert"),
    nnkInfix.newTree(
      newIdentNode("!="),
      newIdentNode("exitCode"),
      newLit(0)
    )
  )
)
#ab1896208 ➡️ 🐛

Diagnostics

metagn introduced a bug at 2024-08-20 22:31:19 +0300 on commit #ab1896208 with message:

sem all call nodes in generic type bodies + many required fixes (#23983)

fixes #23406, closes #23854, closes #23855 (test code of both compiles
but separate issue exists), refs #23432, follows #23411

In generic bodies, previously all regular `nkCall` nodes like `foo(a,
b)` were directly treated as generic statements and delayed immediately,
but other call kinds like `a.foo(b)`, `foo a, b` etc underwent
typechecking before making sure they have to be delayed, as implemented
in #22029. Since the behavior for `nkCall` was slightly buggy (as in
#23406), the behavior for all call kinds is now to call `semTypeExpr`.

However the vast majority of calls in generic bodies out there are
`nkCall`, and while there isn't a difference in the expected behavior,
this exposes many issues with the implementation started in #22029 given
how much more code uses it now. The portion of these issues that CI has
caught are fixed in this PR but it's possible there are more.

1. Deref expressions, dot expressions and calls to dot expressions now
handle and propagate `tyFromExpr`. This is most of the changes in
`semexprs`.
2. For deref expressions to work in `typeof`, a new type flag
`tfNonConstExpr` is added for `tyFromExpr` that calls `semExprWithType`
with `efInTypeof` on the expression instead of `semConstExpr`. This type
flag is set for every `tyFromExpr` type of a node that `prepareNode`
encounters, so that the node itself isn't evaluated at compile time when
just trying to get the type of the node.
3. Unresolved `static` types matching `static` parameters is now treated
the same as unresolved generic types matching `typedesc` parameters in
generic type bodies, it causes a failed match which delays the call
instantiation.
4. `typedesc` parameters now reject all types containing unresolved
generic types like `seq[T]`, not just generic param types by themselves.
(using `containsGenericType`)
5. `semgnrc` now doesn't leave generic param symbols it encounters in
generic type contexts as just identifiers, and instead turns them into
symbol nodes. Normally in generic procs, this isn't a problem since the
generic param symbols will be provided again at instantiation time (and
in fact creating symbol nodes causes issues since `seminst` doesn't
actually instantiate proc body node types).
But generic types can try to be instantiated early in `sigmatch` which
will give an undeclared identifier error when the param is not provided.
Nodes in generic types (specifically in `tyFromExpr` which should be the
only use for `semGenericStmt`) undergo full generic type instantiation
with `prepareNode`, so there is no issue of these symbols remaining as
uninstantiated generic types.
6. `prepareNode` now has more logic for which nodes to avoid
instantiating.
Subscripts and subscripts turned into calls to `[]` by `semgnrc` need to
avoid instantiating the first operand, since it may be a generic body
type like `Generic` in an expression like `Generic[int]`.
Dot expressions cannot instantiate their RHS as it may be a generic proc
symbol or even an undeclared identifier for generic param fields, but
have to instantiate their LHS, so calls and subscripts need to still
instantiate their first node if it's a dot expression.
This logic still isn't perfect and needs the same level of detail as in
`semexprs` for which nodes can be left as "untyped" for overloading/dot
exprs/subscripts to handle, but should handle the majority of cases.

Also the `efDetermineType` requirement for which calls become
`tyFromExpr` is removed and as a result `efDetermineType` is entirely
unused again.

The bug is in the files:

compiler/ast.nim
compiler/semcall.nim
compiler/semexprs.nim
compiler/semgnrc.nim
compiler/semtypes.nim
compiler/semtypinst.nim
compiler/sigmatch.nim
tests/generics/t23854.nim
tests/generics/t23855.nim
tests/generics/tcalltype.nim
tests/generics/tuninstantiatedgenericcalls.nim
tests/metatype/ttypedescnotnimnode.nim
tests/metatype/ttypeselectors.nim

The bug can be in the commits:

(Diagnostics sometimes off-by-one).

Stats
  • GCC 11.4.0
  • Clang 14.0.0
  • NodeJS 20.4
  • Created 2024-10-30T11:36:54Z
  • Comments 2
  • Commands nim c --run -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

🤖 Bug found in 26 mins bisecting 1019 commits at 38 commits per second

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants