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

Double destroy using proc type alias with a sink #23907

Closed
Nycto opened this issue Jul 31, 2024 · 4 comments · Fixed by #23909
Closed

Double destroy using proc type alias with a sink #23907

Nycto opened this issue Jul 31, 2024 · 4 comments · Fixed by #23909

Comments

@Nycto
Copy link
Contributor

Nycto commented Jul 31, 2024

Description

I expect the following code to execute without an errors:

type
    Thingy = object
        value: int

    ExecProc[C] = proc(value: sink C): void

proc `=copy`(a: var Thingy, b: Thingy) {.error.}

var thingyDestroyCount = 0

proc `=destroy`(thingy: Thingy) =
    assert(thingyDestroyCount <= 0)
    thingyDestroyCount  = 1

proc store(value: sink Thingy): void =
    echo value

let callback: ExecProc[Thingy] = store

callback(Thingy(value: 123))

However, it currently tries to call the =destroy proc twice, despite the fact that we are using a sink. This triggers the assert I've got in there.

Note that if you change the let callback line to remove the type definition of ExecProc[Thingy], everything works

Nim Version

Nim Compiler Version 2.0.8 [Linux: amd64]
Compiled at 2024-07-03
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: 5935c3bfa9fec6505394867b23510eb5cbab3dbf
active boot switches: -d:release

Current Output

> nim c -r /tmp/example.nim
Hint: used config file '/home/nycto/.choosenim/toolchains/nim-2.0.8/config/nim.cfg' [Conf]
Hint: used config file '/home/nycto/.choosenim/toolchains/nim-2.0.8/config/config.nims' [Conf]
......................................................................
CC: example.nim
Hint:  [Link]
Hint: mm: orc; threads: on; opt: none (DEBUG BUILD, `-d:release` generates faster code)
27795 lines; 0.438s; 30.32MiB peakmem; proj: /tmp/example.nim; out: /tmp/example [SuccessX]
Hint: /tmp/example [Exec]
(value: 123)
/tmp/example.nim(11)     example
/tmp/example.nim(12)     =destroy
/home/nycto/.choosenim/toolchains/nim-2.0.8/lib/std/assertions.nim(41) failedAssertImpl
/home/nycto/.choosenim/toolchains/nim-2.0.8/lib/std/assertions.nim(36) raiseAssert
/home/nycto/.choosenim/toolchains/nim-2.0.8/lib/system/fatal.nim(53) sysFatal
Error: unhandled exception: /tmp/example.nim(12, 11) `thingyDestroyCount <= 0`  [AssertionDefect]
Error: execution of an external program failed: '/tmp/example'

Expected Output

I expect it not to throw an exception

Possible Solution

No response

Additional Information

No response

@juancarlospaco
Copy link
Collaborator

!nim c

type
    Thingy = object
        value: int

    ExecProc[C] = proc(value: sink C): void

proc `=copy`(a: var Thingy, b: Thingy) {.error.}

var thingyDestroyCount = 0

proc `=destroy`(thingy: Thingy) =
    assert(thingyDestroyCount <= 0)
    thingyDestroyCount  = 1

proc store(value: sink Thingy): void =
    echo value

let callback: ExecProc[Thingy] = store

callback(Thingy(value: 123))

Copy link
Contributor

🐧 Linux bisect by @juancarlospaco (collaborator)
devel 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/temp.nim temp
/home/runner/work/Nim/Nim/temp.nim =destroy
/home/runner/.choosenim/toolchains/nim-#devel/lib/std/assertions.nim failedAssertImpl
/home/runner/.choosenim/toolchains/nim-#devel/lib/std/assertions.nim raiseAssert
/home/runner/.choosenim/toolchains/nim-#devel/lib/system/fatal.nim sysFatal
Error: unhandled exception: /home/runner/work/Nim/Nim/temp.nim(8, 11) `thingyDestroyCount <= 0`  [AssertionDefect]
Error: execution of an external program failed: '/home/runner/work/Nim/Nim/temp'
assertions.nim(34)       raiseAssert
Error: unhandled exception: errGenerated [AssertionDefect]

IR

Compiled filesize 98.87 Kb (101,240 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#define nimfr_(proc, file) \
TFrame FR_; \
FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
#define nimfrs_(proc, file, slots, length) \
 struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename;NI len;VarSlot s[slots];} FR_; \
 FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
#define nimln_(n) \
 FR_.line = n;
#define nimlf_(n, file) \
 FR_.line = n; FR_.filename = file;
typedef struct tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
typedef struct tyObject_RefHeader__YmUax3FsG7Gnj3DF0PcAlw tyObject_RefHeader__YmUax3FsG7Gnj3DF0PcAlw;
typedef struct TNimTypeV2 TNimTypeV2;
typedef struct {
N_NIMCALL_PTR(void, ClP_0) (tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0, void* ClE_0);
void* ClE_0;
} tyProc__57He2SY0oGSpYVIsnenmhw;
struct tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw {
 NI value;
};
struct NimStrPayload {
 NI cap;
 NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
 NI len;
 NimStrPayload* p;
};
typedef NimStringV2 tyArray__nHXaesL0DJZHyVS07ARPRA[1];
typedef N_CLOSURE_PTR(void, TM__SRd76hP9cMfCzdUO857UhQQ_5) (tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0, void* ClE_0);
typedef N_CLOSURE_PTR(void, TM__SRd76hP9cMfCzdUO857UhQQ_6) (tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0);
struct tyObject_RefHeader__YmUax3FsG7Gnj3DF0PcAlw {
 NI rc;
 NI rootIdx;
};
struct TNimTypeV2 {
 void* destructor;
 NI size;
 NI16 align;
 NI16 depth;
 NU32* display;
 void* traceImpl;
 void* typeInfoV1;
 NI flags;
 void* vTable[SEQ_DECL_SIZE];
};
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, store__temp_u22)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, dollar___temp_u54)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw x_p0);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringV2* args_p0, NI args_p0Len_0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u11)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw thingy_p0);
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__stdZassertions_u235)(NimStringV2 msg_p0);
N_LIB_PRIVATE N_NOINLINE(void, raiseOverflow)(void);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4613)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u103)(tyProc__57He2SY0oGSpYVIsnenmhw* dest_p0);
static N_INLINE(NIM_BOOL, nimDecRefIsLastCyclicDyn)(void* p_p0);
static N_INLINE(NI, minuspercent___system_u803)(NI x_p0, NI y_p1);
N_LIB_PRIVATE N_NOINLINE(void, rememberCycle__system_u3461)(NIM_BOOL isDestroyAction_p0, tyObject_RefHeader__YmUax3FsG7Gnj3DF0PcAlw* s_p1, TNimTypeV2* desc_p2);
N_LIB_PRIVATE N_NIMCALL(void, nimDestroyAndDispose)(void* p_p0);
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[68 1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 68 | NIM_STRLIT_FLAG, "/home/runner/work/Nim/Nim/temp.nim(8, 11) `thingyDestroyCount <= 0` " };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {68, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
N_LIB_PRIVATE tyProc__57He2SY0oGSpYVIsnenmhw callback__temp_u99;
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4397;
N_LIB_PRIVATE NI thingyDestroyCount__temp_u10 = ((NI)0);
extern NIM_THREADVAR TFrame* framePtr__system_u2654;
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_u4397);
 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_u2654 == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s_p0).calldepth = ((NI16)0);
 }
 goto LA1_;
LA3_: ;
 {
  (*s_p0).calldepth = (NI16)((*framePtr__system_u2654).calldepth   ((NI16)1));
 }
LA1_: ;
 (*s_p0).prev = framePtr__system_u2654;
 framePtr__system_u2654 = s_p0;
 {
  if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
  callDepthLimitReached__system_u4613();
 }
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__system_u2654 = (*framePtr__system_u2654).prev;
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u11)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw thingy_p0) {
 NI TM__SRd76hP9cMfCzdUO857UhQQ_4;
NIM_BOOL* nimErr_;
 nimfr_("=destroy", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
 {
  if (!!((thingyDestroyCount__temp_u10 <= ((NI)0)))) goto LA3_;
  failedAssertImpl__stdZassertions_u235(TM__SRd76hP9cMfCzdUO857UhQQ_3);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
LA3_: ;
 if (nimAddInt(thingyDestroyCount__temp_u10, ((NI)1), &TM__SRd76hP9cMfCzdUO857UhQQ_4)) { raiseOverflow(); goto BeforeRet_;
 };
 thingyDestroyCount__temp_u10 = (NI)(TM__SRd76hP9cMfCzdUO857UhQQ_4);
 }BeforeRet_: ;
 popFrame();
}
N_LIB_PRIVATE N_NIMCALL(void, store__temp_u22)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0) {
 NimStringV2 colontmpD_;
 tyArray__nHXaesL0DJZHyVS07ARPRA T2_;
NIM_BOOL oldNimErrFin1_;
NIM_BOOL* nimErr_;
 nimfr_("store", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
 colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
 colontmpD_ = dollar___temp_u54(value_p0);
 if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
 T2_[0] = colontmpD_;
 echoBinSafe(T2_, 1);
 {
  LA1_:;
 }
 {
  oldNimErrFin1_ = *nimErr_; *nimErr_ = NIM_FALSE;
  eqdestroy___temp_u11(value_p0);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
  if (colontmpD_.p && !(colontmpD_.p->cap & NIM_STRLIT_FLAG)) {
deallocShared(colontmpD_.p);
}
  *nimErr_ = oldNimErrFin1_;
 }
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }BeforeRet_: ;
 popFrame();
}
static N_INLINE(NI, minuspercent___system_u803)(NI x_p0, NI y_p1) {
 NI result;
 nimfr_("-%", "/home/runner/.choosenim/toolchains/nim-#devel/lib/system/arithmetics.nim");
 result = ((NI) ((NU)((NU64)(((NU) (x_p0))) - (NU64)(((NU) (y_p1))))));
 popFrame();
 return result;
}
static N_INLINE(NIM_BOOL, nimDecRefIsLastCyclicDyn)(void* p_p0) {
 NIM_BOOL result;
NIM_BOOL* nimErr_;
 nimfr_("nimDecRefIsLastCyclicDyn", "/home/runner/.choosenim/toolchains/nim-#devel/lib/system/orc.nim");
{nimErr_ = nimErrorFlag();
 result = (NIM_BOOL)0;
 {
  tyObject_RefHeader__YmUax3FsG7Gnj3DF0PcAlw* cell;
  NI T5_;
  if (!!((p_p0 == NIM_NIL))) goto LA3_;
  T5_ = (NI)0;
  T5_ = minuspercent___system_u803(((NI) (ptrdiff_t) (p_p0)), ((NI)16));
  cell = ((tyObject_RefHeader__YmUax3FsG7Gnj3DF0PcAlw*) (T5_));
  {
   if (!((NI)((*cell).rc & ((NI)-16)) == ((NI)0))) goto LA8_;
   result = NIM_TRUE;
  }
  goto LA6_;
LA8_: ;
  {
   NI TM__SRd76hP9cMfCzdUO857UhQQ_7;
   if (nimSubInt((*cell).rc, ((NI)16), &TM__SRd76hP9cMfCzdUO857UhQQ_7)) { raiseOverflow(); goto BeforeRet_;
   };
   (*cell).rc = (NI)(TM__SRd76hP9cMfCzdUO857UhQQ_7);
  }
LA6_: ;
  rememberCycle__system_u3461(result, cell, (*((TNimTypeV2**) (p_p0))));
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
LA3_: ;
 }BeforeRet_: ;
 popFrame();
 return result;
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u103)(tyProc__57He2SY0oGSpYVIsnenmhw* dest_p0) {
 {
  NIM_BOOL T3_;
  T3_ = (NIM_BOOL)0;
  T3_ = nimDecRefIsLastCyclicDyn((*dest_p0).ClE_0);
  if (!T3_) goto LA4_;
  nimDestroyAndDispose((*dest_p0).ClE_0);
 }
LA4_: ;
}
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) {
{
 tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw colontmpD_;
 tyProc__57He2SY0oGSpYVIsnenmhw T1_;
NIM_BOOL* nimErr_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
 nimZeroMem((void*)(&colontmpD_), sizeof(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw));
 nimZeroMem((void*)(&T1_), sizeof(tyProc__57He2SY0oGSpYVIsnenmhw));
 T1_.ClP_0 = ((TM__SRd76hP9cMfCzdUO857UhQQ_5) (store__temp_u22)); T1_.ClE_0 = NIM_NIL;
 callback__temp_u99.ClE_0 = T1_.ClE_0;
 callback__temp_u99.ClP_0 = T1_.ClP_0;
 colontmpD_.value = ((NI)123);
 callback__temp_u99.ClE_0? callback__temp_u99.ClP_0(colontmpD_, callback__temp_u99.ClE_0):((TM__SRd76hP9cMfCzdUO857UhQQ_6)(callback__temp_u99.ClP_0))(colontmpD_);
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 eqdestroy___temp_u11(colontmpD_);
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 eqdestroy___temp_u103((&callback__temp_u99));
 BeforeRet_: ;
 nimTestErrorFlag();
 popFrame();
}
}

Stats

  • Started 2024-07-31T17:55:05
  • Finished 2024-07-31T17:55:06
  • Duration

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("Thingy"),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("value"),
            newIdentNode("int"),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("ExecProc"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("C"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkProcTy.newTree(
        nnkFormalParams.newTree(
          newIdentNode("void"),
          nnkIdentDefs.newTree(
            newIdentNode("value"),
            nnkCommand.newTree(
              newIdentNode("sink"),
              newIdentNode("C")
            ),
            newEmptyNode()
          )
        ),
        newEmptyNode()
      )
    )
  ),
  nnkProcDef.newTree(
    nnkAccQuoted.newTree(
      newIdentNode("="),
      newIdentNode("copy")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkVarTy.newTree(
          newIdentNode("Thingy")
        ),
        newEmptyNode()
      ),
      nnkIdentDefs.newTree(
        newIdentNode("b"),
        newIdentNode("Thingy"),
        newEmptyNode()
      )
    ),
    nnkPragma.newTree(
      newIdentNode("error")
    ),
    newEmptyNode(),
    newEmptyNode()
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("thingyDestroyCount"),
      newEmptyNode(),
      newLit(0)
    )
  ),
  nnkProcDef.newTree(
    nnkAccQuoted.newTree(
      newIdentNode("="),
      newIdentNode("destroy")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("thingy"),
        newIdentNode("Thingy"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        newIdentNode("assert"),
        nnkInfix.newTree(
          newIdentNode("<="),
          newIdentNode("thingyDestroyCount"),
          newLit(0)
        )
      ),
      nnkInfix.newTree(
        newIdentNode(" ="),
        newIdentNode("thingyDestroyCount"),
        newLit(1)
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("store"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("void"),
      nnkIdentDefs.newTree(
        newIdentNode("value"),
        nnkCommand.newTree(
          newIdentNode("sink"),
          newIdentNode("Thingy")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("value")
      )
    )
  ),
  nnkLetSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("callback"),
      nnkBracketExpr.newTree(
        newIdentNode("ExecProc"),
        newIdentNode("Thingy")
      ),
      newIdentNode("store")
    )
  ),
  nnkCall.newTree(
    newIdentNode("callback"),
    nnkObjConstr.newTree(
      newIdentNode("Thingy"),
      nnkExprColonExpr.newTree(
        newIdentNode("value"),
        newLit(123)
      )
    )
  )
)
stable 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/temp.nim temp
/home/runner/work/Nim/Nim/temp.nim =destroy
/home/runner/.choosenim/toolchains/nim-2.0.8/lib/std/assertions.nim failedAssertImpl
/home/runner/.choosenim/toolchains/nim-2.0.8/lib/std/assertions.nim raiseAssert
/home/runner/.choosenim/toolchains/nim-2.0.8/lib/system/fatal.nim sysFatal
Error: unhandled exception: /home/runner/work/Nim/Nim/temp.nim(8, 11) `thingyDestroyCount <= 0`  [AssertionDefect]
Error: execution of an external program failed: '/home/runner/work/Nim/Nim/temp'
assertions.nim(34)       raiseAssert
Error: unhandled exception: options.nim(682, 5) `false` errGenerated [AssertionDefect]

IR

Compiled filesize 98.83 Kb (101,200 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#define nimfr_(proc, file) \
TFrame FR_; \
FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
#define nimfrs_(proc, file, slots, length) \
 struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename;NI len;VarSlot s[slots];} FR_; \
 FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
#define nimln_(n) \
 FR_.line = n;
#define nimlf_(n, file) \
 FR_.line = n; FR_.filename = file;
typedef struct tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
typedef struct tyObject_RefHeader__m5DjWPRDLSOOpTFPKmlVBA tyObject_RefHeader__m5DjWPRDLSOOpTFPKmlVBA;
typedef struct TNimTypeV2 TNimTypeV2;
typedef struct {
N_NIMCALL_PTR(void, ClP_0) (tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0, void* ClE_0);
void* ClE_0;
} tyProc__57He2SY0oGSpYVIsnenmhw;
struct tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw {
 NI value;
};
struct NimStrPayload {
 NI cap;
 NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
 NI len;
 NimStrPayload* p;
};
typedef NimStringV2 tyArray__nHXaesL0DJZHyVS07ARPRA[1];
typedef N_CLOSURE_PTR(void, TM__SRd76hP9cMfCzdUO857UhQQ_5) (tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0, void* ClE_0);
typedef N_CLOSURE_PTR(void, TM__SRd76hP9cMfCzdUO857UhQQ_6) (tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0);
struct tyObject_RefHeader__m5DjWPRDLSOOpTFPKmlVBA {
 NI rc;
 NI rootIdx;
};
struct TNimTypeV2 {
 void* destructor;
 NI size;
 NI16 align;
 NI16 depth;
 NU32* display;
 void* traceImpl;
 void* typeInfoV1;
 NI flags;
};
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, store__temp_u22)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, dollar___temp_u55)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw x_p0);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringV2* args_p0, NI args_p0Len_0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u11)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw thingy_p0);
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__stdZassertions_u270)(NimStringV2 msg_p0);
N_LIB_PRIVATE N_NOINLINE(void, raiseOverflow)(void);
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_NOCONV(void, deallocShared)(void* p_p0);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u105)(tyProc__57He2SY0oGSpYVIsnenmhw* dest_p0);
static N_INLINE(NIM_BOOL, nimDecRefIsLastCyclicDyn)(void* p_p0);
static N_INLINE(NI, minuspercent___system_u810)(NI x_p0, NI y_p1);
N_LIB_PRIVATE N_NOINLINE(void, rememberCycle__system_u3481)(NIM_BOOL isDestroyAction_p0, tyObject_RefHeader__m5DjWPRDLSOOpTFPKmlVBA* s_p1, TNimTypeV2* desc_p2);
N_LIB_PRIVATE N_NIMCALL(void, nimDestroyAndDispose)(void* p_p0);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot8atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
static const struct {
NI cap; NIM_CHAR data[68 1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 68 | NIM_STRLIT_FLAG, "/home/runner/work/Nim/Nim/temp.nim(8, 11) `thingyDestroyCount <= 0` " };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {68, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
N_LIB_PRIVATE tyProc__57He2SY0oGSpYVIsnenmhw callback__temp_u101;
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4402;
N_LIB_PRIVATE NI thingyDestroyCount__temp_u10 = ((NI)0);
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 N_NIMCALL(void, eqdestroy___temp_u11)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw thingy_p0) {
 NI TM__SRd76hP9cMfCzdUO857UhQQ_4;
NIM_BOOL* nimErr_;
 nimfr_("=destroy", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
 {
  if (!!((thingyDestroyCount__temp_u10 <= ((NI)0)))) goto LA3_;
  failedAssertImpl__stdZassertions_u270(TM__SRd76hP9cMfCzdUO857UhQQ_3);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
LA3_: ;
 if (nimAddInt(thingyDestroyCount__temp_u10, ((NI)1), &TM__SRd76hP9cMfCzdUO857UhQQ_4)) { raiseOverflow(); goto BeforeRet_;
 };
 thingyDestroyCount__temp_u10 = (NI)(TM__SRd76hP9cMfCzdUO857UhQQ_4);
 }BeforeRet_: ;
 popFrame();
}
N_LIB_PRIVATE N_NIMCALL(void, store__temp_u22)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0) {
 NimStringV2 colontmpD_;
 tyArray__nHXaesL0DJZHyVS07ARPRA T2_;
NIM_BOOL oldNimErrFin1_;
NIM_BOOL* nimErr_;
 nimfr_("store", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
 colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
 colontmpD_ = dollar___temp_u55(value_p0);
 if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
 T2_[0] = colontmpD_;
 echoBinSafe(T2_, 1);
 {
  LA1_:;
 }
 {
  oldNimErrFin1_ = *nimErr_; *nimErr_ = NIM_FALSE;
  eqdestroy___temp_u11(value_p0);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
  if (colontmpD_.p && !(colontmpD_.p->cap & NIM_STRLIT_FLAG)) {
deallocShared(colontmpD_.p);
}
  *nimErr_ = oldNimErrFin1_;
 }
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }BeforeRet_: ;
 popFrame();
}
static N_INLINE(NI, minuspercent___system_u810)(NI x_p0, NI y_p1) {
 NI result;
 nimfr_("-%", "/home/runner/.choosenim/toolchains/nim-2.0.8/lib/system/arithmetics.nim");
 result = ((NI) ((NU)((NU64)(((NU) (x_p0))) - (NU64)(((NU) (y_p1))))));
 popFrame();
 return result;
}
static N_INLINE(NIM_BOOL, nimDecRefIsLastCyclicDyn)(void* p_p0) {
 NIM_BOOL result;
NIM_BOOL* nimErr_;
 nimfr_("nimDecRefIsLastCyclicDyn", "/home/runner/.choosenim/toolchains/nim-2.0.8/lib/system/orc.nim");
{nimErr_ = nimErrorFlag();
 result = (NIM_BOOL)0;
 {
  tyObject_RefHeader__m5DjWPRDLSOOpTFPKmlVBA* cell;
  NI T5_;
  if (!!((p_p0 == NIM_NIL))) goto LA3_;
  T5_ = (NI)0;
  T5_ = minuspercent___system_u810(((NI) (ptrdiff_t) (p_p0)), ((NI)16));
  cell = ((tyObject_RefHeader__m5DjWPRDLSOOpTFPKmlVBA*) (T5_));
  {
   if (!((NI)((*cell).rc & ((NI)-16)) == ((NI)0))) goto LA8_;
   result = NIM_TRUE;
  }
  goto LA6_;
LA8_: ;
  {
   NI TM__SRd76hP9cMfCzdUO857UhQQ_7;
   if (nimSubInt((*cell).rc, ((NI)16), &TM__SRd76hP9cMfCzdUO857UhQQ_7)) { raiseOverflow(); goto BeforeRet_;
   };
   (*cell).rc = (NI)(TM__SRd76hP9cMfCzdUO857UhQQ_7);
  }
LA6_: ;
  rememberCycle__system_u3481(result, cell, (*((TNimTypeV2**) (p_p0))));
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
LA3_: ;
 }BeforeRet_: ;
 popFrame();
 return result;
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u105)(tyProc__57He2SY0oGSpYVIsnenmhw* dest_p0) {
 {
  NIM_BOOL T3_;
  T3_ = (NIM_BOOL)0;
  T3_ = nimDecRefIsLastCyclicDyn((*dest_p0).ClE_0);
  if (!T3_) goto LA4_;
  nimDestroyAndDispose((*dest_p0).ClE_0);
 }
LA4_: ;
}
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;
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot8atslibatssystemdotnim_Init000();
 (*inner)();
#else
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot8atslibatssystemdotnim_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) {
{
 tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw colontmpD_;
 tyProc__57He2SY0oGSpYVIsnenmhw T1_;
NIM_BOOL* nimErr_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
 nimZeroMem((void*)(&colontmpD_), sizeof(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw));
 nimZeroMem((void*)(&T1_), sizeof(tyProc__57He2SY0oGSpYVIsnenmhw));
 T1_.ClP_0 = ((TM__SRd76hP9cMfCzdUO857UhQQ_5) (store__temp_u22)); T1_.ClE_0 = NIM_NIL;
 callback__temp_u101.ClE_0 = T1_.ClE_0;
 callback__temp_u101.ClP_0 = T1_.ClP_0;
 colontmpD_.value = ((NI)123);
 callback__temp_u101.ClE_0? callback__temp_u101.ClP_0(colontmpD_, callback__temp_u101.ClE_0):((TM__SRd76hP9cMfCzdUO857UhQQ_6)(callback__temp_u101.ClP_0))(colontmpD_);
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 eqdestroy___temp_u11(colontmpD_);
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 eqdestroy___temp_u105((&callback__temp_u101));
 BeforeRet_: ;
 nimTestErrorFlag();
 popFrame();
}
}

Stats

  • Started 2024-07-31T17:55:10
  • Finished 2024-07-31T17:55:10
  • Duration

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("Thingy"),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("value"),
            newIdentNode("int"),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("ExecProc"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("C"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkProcTy.newTree(
        nnkFormalParams.newTree(
          newIdentNode("void"),
          nnkIdentDefs.newTree(
            newIdentNode("value"),
            nnkCommand.newTree(
              newIdentNode("sink"),
              newIdentNode("C")
            ),
            newEmptyNode()
          )
        ),
        newEmptyNode()
      )
    )
  ),
  nnkProcDef.newTree(
    nnkAccQuoted.newTree(
      newIdentNode("="),
      newIdentNode("copy")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkVarTy.newTree(
          newIdentNode("Thingy")
        ),
        newEmptyNode()
      ),
      nnkIdentDefs.newTree(
        newIdentNode("b"),
        newIdentNode("Thingy"),
        newEmptyNode()
      )
    ),
    nnkPragma.newTree(
      newIdentNode("error")
    ),
    newEmptyNode(),
    newEmptyNode()
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("thingyDestroyCount"),
      newEmptyNode(),
      newLit(0)
    )
  ),
  nnkProcDef.newTree(
    nnkAccQuoted.newTree(
      newIdentNode("="),
      newIdentNode("destroy")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("thingy"),
        newIdentNode("Thingy"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        newIdentNode("assert"),
        nnkInfix.newTree(
          newIdentNode("<="),
          newIdentNode("thingyDestroyCount"),
          newLit(0)
        )
      ),
      nnkInfix.newTree(
        newIdentNode(" ="),
        newIdentNode("thingyDestroyCount"),
        newLit(1)
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("store"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("void"),
      nnkIdentDefs.newTree(
        newIdentNode("value"),
        nnkCommand.newTree(
          newIdentNode("sink"),
          newIdentNode("Thingy")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("value")
      )
    )
  ),
  nnkLetSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("callback"),
      nnkBracketExpr.newTree(
        newIdentNode("ExecProc"),
        newIdentNode("Thingy")
      ),
      newIdentNode("store")
    )
  ),
  nnkCall.newTree(
    newIdentNode("callback"),
    nnkObjConstr.newTree(
      newIdentNode("Thingy"),
      nnkExprColonExpr.newTree(
        newIdentNode("value"),
        newLit(123)
      )
    )
  )
)
2.0.4 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/temp.nim temp
/home/runner/work/Nim/Nim/temp.nim =destroy
/home/runner/.choosenim/toolchains/nim-2.0.4/lib/std/assertions.nim failedAssertImpl
/home/runner/.choosenim/toolchains/nim-2.0.4/lib/std/assertions.nim raiseAssert
/home/runner/.choosenim/toolchains/nim-2.0.4/lib/system/fatal.nim sysFatal
Error: unhandled exception: /home/runner/work/Nim/Nim/temp.nim(8, 11) `thingyDestroyCount <= 0`  [AssertionDefect]
Error: execution of an external program failed: '/home/runner/work/Nim/Nim/temp'
assertions.nim(34)       raiseAssert
Error: unhandled exception: options.nim(681, 5) `false` errGenerated [AssertionDefect]

IR

Compiled filesize 96.89 Kb (99,216 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#define nimfr_(proc, file) \
TFrame FR_; \
FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
#define nimfrs_(proc, file, slots, length) \
 struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename;NI len;VarSlot s[slots];} FR_; \
 FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
#define nimln_(n) \
 FR_.line = n;
#define nimlf_(n, file) \
 FR_.line = n; FR_.filename = file;
typedef struct tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
typedef struct tyObject_RefHeader__bT6rHCap81aoFk2UwTCpIw tyObject_RefHeader__bT6rHCap81aoFk2UwTCpIw;
typedef struct TNimTypeV2 TNimTypeV2;
typedef struct {
N_NIMCALL_PTR(void, ClP_0) (tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0, void* ClE_0);
void* ClE_0;
} tyProc__57He2SY0oGSpYVIsnenmhw;
struct tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw {
 NI value;
};
struct NimStrPayload {
 NI cap;
 NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
 NI len;
 NimStrPayload* p;
};
typedef NimStringV2 tyArray__nHXaesL0DJZHyVS07ARPRA[1];
typedef N_CLOSURE_PTR(void, TM__SRd76hP9cMfCzdUO857UhQQ_5) (tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0, void* ClE_0);
typedef N_CLOSURE_PTR(void, TM__SRd76hP9cMfCzdUO857UhQQ_6) (tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0);
struct tyObject_RefHeader__bT6rHCap81aoFk2UwTCpIw {
 NI rc;
 NI rootIdx;
};
struct TNimTypeV2 {
 void* destructor;
 NI size;
 NI16 align;
 NI16 depth;
 NU32* display;
 void* traceImpl;
 void* typeInfoV1;
 NI flags;
};
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, store__temp_u22)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, dollar___temp_u55)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw x_p0);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringV2* args_p0, NI args_p0Len_0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u11)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw thingy_p0);
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__stdZassertions_u310)(NimStringV2 msg_p0);
N_LIB_PRIVATE N_NOINLINE(void, raiseOverflow)(void);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4621)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u105)(tyProc__57He2SY0oGSpYVIsnenmhw* dest_p0);
static N_INLINE(NIM_BOOL, nimDecRefIsLastCyclicDyn)(void* p_p0);
static N_INLINE(NI, minuspercent___system_u810)(NI x_p0, NI y_p1);
N_LIB_PRIVATE N_NOINLINE(void, rememberCycle__system_u3417)(NIM_BOOL isDestroyAction_p0, tyObject_RefHeader__bT6rHCap81aoFk2UwTCpIw* s_p1, TNimTypeV2* desc_p2);
N_LIB_PRIVATE N_NIMCALL(void, nimDestroyAndDispose)(void* p_p0);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot4atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
static const struct {
NI cap; NIM_CHAR data[68 1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 68 | NIM_STRLIT_FLAG, "/home/runner/work/Nim/Nim/temp.nim(8, 11) `thingyDestroyCount <= 0` " };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {68, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
N_LIB_PRIVATE tyProc__57He2SY0oGSpYVIsnenmhw callback__temp_u101;
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4403;
N_LIB_PRIVATE NI thingyDestroyCount__temp_u10 = ((NI)0);
extern NIM_THREADVAR TFrame* framePtr__system_u4020;
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_u4403);
 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_u4020 == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s_p0).calldepth = ((NI16)0);
 }
 goto LA1_;
LA3_: ;
 {
  (*s_p0).calldepth = (NI16)((*framePtr__system_u4020).calldepth   ((NI16)1));
 }
LA1_: ;
 (*s_p0).prev = framePtr__system_u4020;
 framePtr__system_u4020 = s_p0;
 {
  if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
  callDepthLimitReached__system_u4621();
 }
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__system_u4020 = (*framePtr__system_u4020).prev;
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u11)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw thingy_p0) {
 NI TM__SRd76hP9cMfCzdUO857UhQQ_4;
NIM_BOOL* nimErr_;
 nimfr_("=destroy", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
 {
  if (!!((thingyDestroyCount__temp_u10 <= ((NI)0)))) goto LA3_;
  failedAssertImpl__stdZassertions_u310(TM__SRd76hP9cMfCzdUO857UhQQ_3);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
LA3_: ;
 if (nimAddInt(thingyDestroyCount__temp_u10, ((NI)1), &TM__SRd76hP9cMfCzdUO857UhQQ_4)) { raiseOverflow(); goto BeforeRet_;
 };
 thingyDestroyCount__temp_u10 = (NI)(TM__SRd76hP9cMfCzdUO857UhQQ_4);
 }BeforeRet_: ;
 popFrame();
}
N_LIB_PRIVATE N_NIMCALL(void, store__temp_u22)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0) {
 NimStringV2 colontmpD_;
 tyArray__nHXaesL0DJZHyVS07ARPRA T2_;
NIM_BOOL oldNimErrFin1_;
NIM_BOOL* nimErr_;
 nimfr_("store", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
 colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
 colontmpD_ = dollar___temp_u55(value_p0);
 if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
 T2_[0] = colontmpD_;
 echoBinSafe(T2_, 1);
 {
  LA1_:;
 }
 {
  oldNimErrFin1_ = *nimErr_; *nimErr_ = NIM_FALSE;
  eqdestroy___temp_u11(value_p0);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
  if (colontmpD_.p && !(colontmpD_.p->cap & NIM_STRLIT_FLAG)) {
deallocShared(colontmpD_.p);
}
  *nimErr_ = oldNimErrFin1_;
 }
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }BeforeRet_: ;
 popFrame();
}
static N_INLINE(NI, minuspercent___system_u810)(NI x_p0, NI y_p1) {
 NI result;
 nimfr_("-%", "/home/runner/.choosenim/toolchains/nim-2.0.4/lib/system/arithmetics.nim");
 result = ((NI) ((NU)((NU64)(((NU) (x_p0))) - (NU64)(((NU) (y_p1))))));
 popFrame();
 return result;
}
static N_INLINE(NIM_BOOL, nimDecRefIsLastCyclicDyn)(void* p_p0) {
 NIM_BOOL result;
NIM_BOOL* nimErr_;
 nimfr_("nimDecRefIsLastCyclicDyn", "/home/runner/.choosenim/toolchains/nim-2.0.4/lib/system/orc.nim");
{nimErr_ = nimErrorFlag();
 result = (NIM_BOOL)0;
 {
  tyObject_RefHeader__bT6rHCap81aoFk2UwTCpIw* cell;
  NI T5_;
  if (!!((p_p0 == NIM_NIL))) goto LA3_;
  T5_ = (NI)0;
  T5_ = minuspercent___system_u810(((NI) (ptrdiff_t) (p_p0)), ((NI)16));
  cell = ((tyObject_RefHeader__bT6rHCap81aoFk2UwTCpIw*) (T5_));
  {
   if (!((NI)((*cell).rc & ((NI)-16)) == ((NI)0))) goto LA8_;
   result = NIM_TRUE;
  }
  goto LA6_;
LA8_: ;
  {
   NI TM__SRd76hP9cMfCzdUO857UhQQ_7;
   if (nimSubInt((*cell).rc, ((NI)16), &TM__SRd76hP9cMfCzdUO857UhQQ_7)) { raiseOverflow(); goto BeforeRet_;
   };
   (*cell).rc = (NI)(TM__SRd76hP9cMfCzdUO857UhQQ_7);
  }
LA6_: ;
  rememberCycle__system_u3417(result, cell, (*((TNimTypeV2**) (p_p0))));
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
LA3_: ;
 }BeforeRet_: ;
 popFrame();
 return result;
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u105)(tyProc__57He2SY0oGSpYVIsnenmhw* dest_p0) {
 {
  NIM_BOOL T3_;
  T3_ = (NIM_BOOL)0;
  T3_ = nimDecRefIsLastCyclicDyn((*dest_p0).ClE_0);
  if (!T3_) goto LA4_;
  nimDestroyAndDispose((*dest_p0).ClE_0);
 }
LA4_: ;
}
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;
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot4atslibatssystemdotnim_Init000();
 (*inner)();
#else
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot4atslibatssystemdotnim_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) {
{
 tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw colontmpD_;
 tyProc__57He2SY0oGSpYVIsnenmhw T1_;
NIM_BOOL* nimErr_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
 nimZeroMem((void*)(&colontmpD_), sizeof(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw));
 nimZeroMem((void*)(&T1_), sizeof(tyProc__57He2SY0oGSpYVIsnenmhw));
 T1_.ClP_0 = ((TM__SRd76hP9cMfCzdUO857UhQQ_5) (store__temp_u22)); T1_.ClE_0 = NIM_NIL;
 callback__temp_u101.ClE_0 = T1_.ClE_0;
 callback__temp_u101.ClP_0 = T1_.ClP_0;
 colontmpD_.value = ((NI)123);
 callback__temp_u101.ClE_0? callback__temp_u101.ClP_0(colontmpD_, callback__temp_u101.ClE_0):((TM__SRd76hP9cMfCzdUO857UhQQ_6)(callback__temp_u101.ClP_0))(colontmpD_);
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 eqdestroy___temp_u11(colontmpD_);
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 eqdestroy___temp_u105((&callback__temp_u101));
 BeforeRet_: ;
 nimTestErrorFlag();
 popFrame();
}
}

Stats

  • Started 2024-07-31T17:55:14
  • Finished 2024-07-31T17:55:14
  • Duration

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("Thingy"),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("value"),
            newIdentNode("int"),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("ExecProc"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("C"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkProcTy.newTree(
        nnkFormalParams.newTree(
          newIdentNode("void"),
          nnkIdentDefs.newTree(
            newIdentNode("value"),
            nnkCommand.newTree(
              newIdentNode("sink"),
              newIdentNode("C")
            ),
            newEmptyNode()
          )
        ),
        newEmptyNode()
      )
    )
  ),
  nnkProcDef.newTree(
    nnkAccQuoted.newTree(
      newIdentNode("="),
      newIdentNode("copy")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkVarTy.newTree(
          newIdentNode("Thingy")
        ),
        newEmptyNode()
      ),
      nnkIdentDefs.newTree(
        newIdentNode("b"),
        newIdentNode("Thingy"),
        newEmptyNode()
      )
    ),
    nnkPragma.newTree(
      newIdentNode("error")
    ),
    newEmptyNode(),
    newEmptyNode()
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("thingyDestroyCount"),
      newEmptyNode(),
      newLit(0)
    )
  ),
  nnkProcDef.newTree(
    nnkAccQuoted.newTree(
      newIdentNode("="),
      newIdentNode("destroy")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("thingy"),
        newIdentNode("Thingy"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        newIdentNode("assert"),
        nnkInfix.newTree(
          newIdentNode("<="),
          newIdentNode("thingyDestroyCount"),
          newLit(0)
        )
      ),
      nnkInfix.newTree(
        newIdentNode(" ="),
        newIdentNode("thingyDestroyCount"),
        newLit(1)
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("store"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("void"),
      nnkIdentDefs.newTree(
        newIdentNode("value"),
        nnkCommand.newTree(
          newIdentNode("sink"),
          newIdentNode("Thingy")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("value")
      )
    )
  ),
  nnkLetSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("callback"),
      nnkBracketExpr.newTree(
        newIdentNode("ExecProc"),
        newIdentNode("Thingy")
      ),
      newIdentNode("store")
    )
  ),
  nnkCall.newTree(
    newIdentNode("callback"),
    nnkObjConstr.newTree(
      newIdentNode("Thingy"),
      nnkExprColonExpr.newTree(
        newIdentNode("value"),
        newLit(123)
      )
    )
  )
)
2.0.0 👍 OK

Output

(value: 123)

IR

Compiled filesize 96.89 Kb (99,216 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#define nimfr_(proc, file) \
TFrame FR_; \
FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
#define nimfrs_(proc, file, slots, length) \
 struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename;NI len;VarSlot s[slots];} FR_; \
 FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
#define nimln_(n) \
 FR_.line = n;
#define nimlf_(n, file) \
 FR_.line = n; FR_.filename = file;
typedef struct tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
typedef struct tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag;
typedef struct TNimTypeV2 TNimTypeV2;
typedef struct {
N_NIMCALL_PTR(void, ClP_0) (tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0, void* ClE_0);
void* ClE_0;
} tyProc__57He2SY0oGSpYVIsnenmhw;
struct tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw {
 NI value;
};
struct NimStrPayload {
 NI cap;
 NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
 NI len;
 NimStrPayload* p;
};
typedef NimStringV2 tyArray__nHXaesL0DJZHyVS07ARPRA[1];
typedef N_CLOSURE_PTR(void, TM__SRd76hP9cMfCzdUO857UhQQ_5) (tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0, void* ClE_0);
typedef N_CLOSURE_PTR(void, TM__SRd76hP9cMfCzdUO857UhQQ_6) (tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0);
struct tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag {
 NI rc;
 NI rootIdx;
};
struct TNimTypeV2 {
 void* destructor;
 NI size;
 NI16 align;
 NI16 depth;
 NU32* display;
 void* traceImpl;
 void* typeInfoV1;
 NI flags;
};
N_LIB_PRIVATE N_NIMCALL(void, store__temp_u22)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, dollar___temp_u55)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw x_p0);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringV2* args_p0, NI args_p0Len_0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u11)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw thingy_p0);
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__stdZassertions_u310)(NimStringV2 msg_p0);
N_LIB_PRIVATE N_NOINLINE(void, raiseOverflow)(void);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4607)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
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);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u105)(tyProc__57He2SY0oGSpYVIsnenmhw* dest_p0);
static N_INLINE(NIM_BOOL, nimDecRefIsLastCyclicDyn)(void* p_p0);
static N_INLINE(NI, minuspercent___system_u810)(NI x_p0, NI y_p1);
N_LIB_PRIVATE N_NOINLINE(void, rememberCycle__system_u3403)(NIM_BOOL isDestroyAction_p0, tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag* s_p1, TNimTypeV2* desc_p2);
N_LIB_PRIVATE N_NIMCALL(void, nimDestroyAndDispose)(void* p_p0);
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[68 1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 68 | NIM_STRLIT_FLAG, "/home/runner/work/Nim/Nim/temp.nim(8, 11) `thingyDestroyCount <= 0` " };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {68, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
N_LIB_PRIVATE tyProc__57He2SY0oGSpYVIsnenmhw callback__temp_u101;
N_LIB_PRIVATE NI thingyDestroyCount__temp_u10 = ((NI)0);
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4389;
extern NIM_THREADVAR TFrame* framePtr__system_u4006;
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
 NIM_BOOL* result;
 result = (NIM_BOOL*)0;
 result = (&nimInErrorMode__system_u4389);
 return result;
}
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
 {
  if (!(framePtr__system_u4006 == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s_p0).calldepth = ((NI16)0);
 }
 goto LA1_;
LA3_: ;
 {
  (*s_p0).calldepth = (NI16)((*framePtr__system_u4006).calldepth   ((NI16)1));
 }
LA1_: ;
 (*s_p0).prev = framePtr__system_u4006;
 framePtr__system_u4006 = s_p0;
 {
  if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
  callDepthLimitReached__system_u4607();
 }
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__system_u4006 = (*framePtr__system_u4006).prev;
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u11)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw thingy_p0) {
 NI TM__SRd76hP9cMfCzdUO857UhQQ_4;
NIM_BOOL* nimErr_;
 nimfr_("=destroy", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
 {
  if (!!((thingyDestroyCount__temp_u10 <= ((NI)0)))) goto LA3_;
  failedAssertImpl__stdZassertions_u310(TM__SRd76hP9cMfCzdUO857UhQQ_3);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
LA3_: ;
 if (nimAddInt(thingyDestroyCount__temp_u10, ((NI)1), &TM__SRd76hP9cMfCzdUO857UhQQ_4)) { raiseOverflow(); goto BeforeRet_;
 };
 thingyDestroyCount__temp_u10 = (NI)(TM__SRd76hP9cMfCzdUO857UhQQ_4);
 }BeforeRet_: ;
 popFrame();
}
N_LIB_PRIVATE N_NIMCALL(void, store__temp_u22)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0) {
 NimStringV2 colontmpD_;
 tyArray__nHXaesL0DJZHyVS07ARPRA T2_;
NIM_BOOL oldNimErrFin1_;
NIM_BOOL* nimErr_;
 nimfr_("store", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
 colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
 colontmpD_ = dollar___temp_u55(value_p0);
 if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
 T2_[0] = colontmpD_;
 echoBinSafe(T2_, 1);
 {
  LA1_:;
 }
 {
  oldNimErrFin1_ = *nimErr_; *nimErr_ = NIM_FALSE;
  eqdestroy___temp_u11(value_p0);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
  if (colontmpD_.p && !(colontmpD_.p->cap & NIM_STRLIT_FLAG)) {
deallocShared(colontmpD_.p);
}
  *nimErr_ = oldNimErrFin1_;
 }
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }BeforeRet_: ;
 popFrame();
}
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(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(NI, minuspercent___system_u810)(NI x_p0, NI y_p1) {
 NI result;
 nimfr_("-%", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arithmetics.nim");
 result = (NI)0;
 result = ((NI) ((NU)((NU64)(((NU) (x_p0))) - (NU64)(((NU) (y_p1))))));
 popFrame();
 return result;
}
static N_INLINE(NIM_BOOL, nimDecRefIsLastCyclicDyn)(void* p_p0) {
 NIM_BOOL result;
NIM_BOOL* nimErr_;
 nimfr_("nimDecRefIsLastCyclicDyn", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/orc.nim");
{nimErr_ = nimErrorFlag();
 result = (NIM_BOOL)0;
 {
  tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag* cell;
  NI T5_;
  if (!!((p_p0 == NIM_NIL))) goto LA3_;
  T5_ = (NI)0;
  T5_ = minuspercent___system_u810(((NI) (ptrdiff_t) (p_p0)), ((NI)16));
  cell = ((tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag*) (T5_));
  {
   if (!((NI)((*cell).rc & ((NI)-16)) == ((NI)0))) goto LA8_;
   result = NIM_TRUE;
  }
  goto LA6_;
LA8_: ;
  {
   NI TM__SRd76hP9cMfCzdUO857UhQQ_7;
   if (nimSubInt((*cell).rc, ((NI)16), &TM__SRd76hP9cMfCzdUO857UhQQ_7)) { raiseOverflow(); goto BeforeRet_;
   };
   (*cell).rc = (NI)(TM__SRd76hP9cMfCzdUO857UhQQ_7);
  }
LA6_: ;
  rememberCycle__system_u3403(result, cell, (*((TNimTypeV2**) (p_p0))));
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
LA3_: ;
 }BeforeRet_: ;
 popFrame();
 return result;
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u105)(tyProc__57He2SY0oGSpYVIsnenmhw* dest_p0) {
 {
  NIM_BOOL T3_;
  T3_ = (NIM_BOOL)0;
  T3_ = nimDecRefIsLastCyclicDyn((*dest_p0).ClE_0);
  if (!T3_) goto LA4_;
  nimDestroyAndDispose((*dest_p0).ClE_0);
 }
LA4_: ;
}
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) {
{
 tyProc__57He2SY0oGSpYVIsnenmhw T1_;
 tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw T2_;
NIM_BOOL* nimErr_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
 nimZeroMem((void*)(&T1_), sizeof(tyProc__57He2SY0oGSpYVIsnenmhw));
 T1_.ClP_0 = ((TM__SRd76hP9cMfCzdUO857UhQQ_5) (store__temp_u22)); T1_.ClE_0 = NIM_NIL;
 callback__temp_u101.ClE_0 = T1_.ClE_0;
 callback__temp_u101.ClP_0 = T1_.ClP_0;
 nimZeroMem((void*)(&T2_), sizeof(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw));
 T2_.value = ((NI)123);
 callback__temp_u101.ClE_0? callback__temp_u101.ClP_0(T2_, callback__temp_u101.ClE_0):((TM__SRd76hP9cMfCzdUO857UhQQ_6)(callback__temp_u101.ClP_0))(T2_);
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 eqdestroy___temp_u105((&callback__temp_u101));
 BeforeRet_: ;
 nimTestErrorFlag();
 popFrame();
}
}

Stats

  • Started 2024-07-31T17:55:17
  • Finished 2024-07-31T17:55:18
  • Duration
1.6.20 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/temp.nim(7, 1) Error: signature for '=destroy' must be proc[T: object](x: var T)
fatal.nim(54)            sysFatal
Error: unhandled exception: options.nim(662, 14) `false` errGenerated [AssertionDefect]

IR

Compiled filesize 96.89 Kb (99,216 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#define nimfr_(proc, file) \
TFrame FR_; \
FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
#define nimfrs_(proc, file, slots, length) \
 struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename;NI len;VarSlot s[slots];} FR_; \
 FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
#define nimln_(n) \
 FR_.line = n;
#define nimlf_(n, file) \
 FR_.line = n; FR_.filename = file;
typedef struct tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
typedef struct tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag;
typedef struct TNimTypeV2 TNimTypeV2;
typedef struct {
N_NIMCALL_PTR(void, ClP_0) (tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0, void* ClE_0);
void* ClE_0;
} tyProc__57He2SY0oGSpYVIsnenmhw;
struct tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw {
 NI value;
};
struct NimStrPayload {
 NI cap;
 NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
 NI len;
 NimStrPayload* p;
};
typedef NimStringV2 tyArray__nHXaesL0DJZHyVS07ARPRA[1];
typedef N_CLOSURE_PTR(void, TM__SRd76hP9cMfCzdUO857UhQQ_5) (tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0, void* ClE_0);
typedef N_CLOSURE_PTR(void, TM__SRd76hP9cMfCzdUO857UhQQ_6) (tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0);
struct tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag {
 NI rc;
 NI rootIdx;
};
struct TNimTypeV2 {
 void* destructor;
 NI size;
 NI16 align;
 NI16 depth;
 NU32* display;
 void* traceImpl;
 void* typeInfoV1;
 NI flags;
};
N_LIB_PRIVATE N_NIMCALL(void, store__temp_u22)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, dollar___temp_u55)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw x_p0);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringV2* args_p0, NI args_p0Len_0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u11)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw thingy_p0);
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__stdZassertions_u310)(NimStringV2 msg_p0);
N_LIB_PRIVATE N_NOINLINE(void, raiseOverflow)(void);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4607)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
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);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u105)(tyProc__57He2SY0oGSpYVIsnenmhw* dest_p0);
static N_INLINE(NIM_BOOL, nimDecRefIsLastCyclicDyn)(void* p_p0);
static N_INLINE(NI, minuspercent___system_u810)(NI x_p0, NI y_p1);
N_LIB_PRIVATE N_NOINLINE(void, rememberCycle__system_u3403)(NIM_BOOL isDestroyAction_p0, tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag* s_p1, TNimTypeV2* desc_p2);
N_LIB_PRIVATE N_NIMCALL(void, nimDestroyAndDispose)(void* p_p0);
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[68 1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 68 | NIM_STRLIT_FLAG, "/home/runner/work/Nim/Nim/temp.nim(8, 11) `thingyDestroyCount <= 0` " };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {68, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
N_LIB_PRIVATE tyProc__57He2SY0oGSpYVIsnenmhw callback__temp_u101;
N_LIB_PRIVATE NI thingyDestroyCount__temp_u10 = ((NI)0);
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4389;
extern NIM_THREADVAR TFrame* framePtr__system_u4006;
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
 NIM_BOOL* result;
 result = (NIM_BOOL*)0;
 result = (&nimInErrorMode__system_u4389);
 return result;
}
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
 {
  if (!(framePtr__system_u4006 == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s_p0).calldepth = ((NI16)0);
 }
 goto LA1_;
LA3_: ;
 {
  (*s_p0).calldepth = (NI16)((*framePtr__system_u4006).calldepth   ((NI16)1));
 }
LA1_: ;
 (*s_p0).prev = framePtr__system_u4006;
 framePtr__system_u4006 = s_p0;
 {
  if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
  callDepthLimitReached__system_u4607();
 }
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__system_u4006 = (*framePtr__system_u4006).prev;
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u11)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw thingy_p0) {
 NI TM__SRd76hP9cMfCzdUO857UhQQ_4;
NIM_BOOL* nimErr_;
 nimfr_("=destroy", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
 {
  if (!!((thingyDestroyCount__temp_u10 <= ((NI)0)))) goto LA3_;
  failedAssertImpl__stdZassertions_u310(TM__SRd76hP9cMfCzdUO857UhQQ_3);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
LA3_: ;
 if (nimAddInt(thingyDestroyCount__temp_u10, ((NI)1), &TM__SRd76hP9cMfCzdUO857UhQQ_4)) { raiseOverflow(); goto BeforeRet_;
 };
 thingyDestroyCount__temp_u10 = (NI)(TM__SRd76hP9cMfCzdUO857UhQQ_4);
 }BeforeRet_: ;
 popFrame();
}
N_LIB_PRIVATE N_NIMCALL(void, store__temp_u22)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0) {
 NimStringV2 colontmpD_;
 tyArray__nHXaesL0DJZHyVS07ARPRA T2_;
NIM_BOOL oldNimErrFin1_;
NIM_BOOL* nimErr_;
 nimfr_("store", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
 colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
 colontmpD_ = dollar___temp_u55(value_p0);
 if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
 T2_[0] = colontmpD_;
 echoBinSafe(T2_, 1);
 {
  LA1_:;
 }
 {
  oldNimErrFin1_ = *nimErr_; *nimErr_ = NIM_FALSE;
  eqdestroy___temp_u11(value_p0);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
  if (colontmpD_.p && !(colontmpD_.p->cap & NIM_STRLIT_FLAG)) {
deallocShared(colontmpD_.p);
}
  *nimErr_ = oldNimErrFin1_;
 }
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }BeforeRet_: ;
 popFrame();
}
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(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(NI, minuspercent___system_u810)(NI x_p0, NI y_p1) {
 NI result;
 nimfr_("-%", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arithmetics.nim");
 result = (NI)0;
 result = ((NI) ((NU)((NU64)(((NU) (x_p0))) - (NU64)(((NU) (y_p1))))));
 popFrame();
 return result;
}
static N_INLINE(NIM_BOOL, nimDecRefIsLastCyclicDyn)(void* p_p0) {
 NIM_BOOL result;
NIM_BOOL* nimErr_;
 nimfr_("nimDecRefIsLastCyclicDyn", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/orc.nim");
{nimErr_ = nimErrorFlag();
 result = (NIM_BOOL)0;
 {
  tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag* cell;
  NI T5_;
  if (!!((p_p0 == NIM_NIL))) goto LA3_;
  T5_ = (NI)0;
  T5_ = minuspercent___system_u810(((NI) (ptrdiff_t) (p_p0)), ((NI)16));
  cell = ((tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag*) (T5_));
  {
   if (!((NI)((*cell).rc & ((NI)-16)) == ((NI)0))) goto LA8_;
   result = NIM_TRUE;
  }
  goto LA6_;
LA8_: ;
  {
   NI TM__SRd76hP9cMfCzdUO857UhQQ_7;
   if (nimSubInt((*cell).rc, ((NI)16), &TM__SRd76hP9cMfCzdUO857UhQQ_7)) { raiseOverflow(); goto BeforeRet_;
   };
   (*cell).rc = (NI)(TM__SRd76hP9cMfCzdUO857UhQQ_7);
  }
LA6_: ;
  rememberCycle__system_u3403(result, cell, (*((TNimTypeV2**) (p_p0))));
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
LA3_: ;
 }BeforeRet_: ;
 popFrame();
 return result;
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u105)(tyProc__57He2SY0oGSpYVIsnenmhw* dest_p0) {
 {
  NIM_BOOL T3_;
  T3_ = (NIM_BOOL)0;
  T3_ = nimDecRefIsLastCyclicDyn((*dest_p0).ClE_0);
  if (!T3_) goto LA4_;
  nimDestroyAndDispose((*dest_p0).ClE_0);
 }
LA4_: ;
}
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) {
{
 tyProc__57He2SY0oGSpYVIsnenmhw T1_;
 tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw T2_;
NIM_BOOL* nimErr_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
 nimZeroMem((void*)(&T1_), sizeof(tyProc__57He2SY0oGSpYVIsnenmhw));
 T1_.ClP_0 = ((TM__SRd76hP9cMfCzdUO857UhQQ_5) (store__temp_u22)); T1_.ClE_0 = NIM_NIL;
 callback__temp_u101.ClE_0 = T1_.ClE_0;
 callback__temp_u101.ClP_0 = T1_.ClP_0;
 nimZeroMem((void*)(&T2_), sizeof(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw));
 T2_.value = ((NI)123);
 callback__temp_u101.ClE_0? callback__temp_u101.ClP_0(T2_, callback__temp_u101.ClE_0):((TM__SRd76hP9cMfCzdUO857UhQQ_6)(callback__temp_u101.ClP_0))(T2_);
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 eqdestroy___temp_u105((&callback__temp_u101));
 BeforeRet_: ;
 nimTestErrorFlag();
 popFrame();
}
}

Stats

  • Started 2024-07-31T17:55:20
  • Finished 2024-07-31T17:55:20
  • Duration

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("Thingy"),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("value"),
            newIdentNode("int"),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("ExecProc"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("C"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkProcTy.newTree(
        nnkFormalParams.newTree(
          newIdentNode("void"),
          nnkIdentDefs.newTree(
            newIdentNode("value"),
            nnkCommand.newTree(
              newIdentNode("sink"),
              newIdentNode("C")
            ),
            newEmptyNode()
          )
        ),
        newEmptyNode()
      )
    )
  ),
  nnkProcDef.newTree(
    nnkAccQuoted.newTree(
      newIdentNode("="),
      newIdentNode("copy")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkVarTy.newTree(
          newIdentNode("Thingy")
        ),
        newEmptyNode()
      ),
      nnkIdentDefs.newTree(
        newIdentNode("b"),
        newIdentNode("Thingy"),
        newEmptyNode()
      )
    ),
    nnkPragma.newTree(
      newIdentNode("error")
    ),
    newEmptyNode(),
    newEmptyNode()
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("thingyDestroyCount"),
      newEmptyNode(),
      newLit(0)
    )
  ),
  nnkProcDef.newTree(
    nnkAccQuoted.newTree(
      newIdentNode("="),
      newIdentNode("destroy")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("thingy"),
        newIdentNode("Thingy"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        newIdentNode("assert"),
        nnkInfix.newTree(
          newIdentNode("<="),
          newIdentNode("thingyDestroyCount"),
          newLit(0)
        )
      ),
      nnkInfix.newTree(
        newIdentNode(" ="),
        newIdentNode("thingyDestroyCount"),
        newLit(1)
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("store"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("void"),
      nnkIdentDefs.newTree(
        newIdentNode("value"),
        nnkCommand.newTree(
          newIdentNode("sink"),
          newIdentNode("Thingy")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("value")
      )
    )
  ),
  nnkLetSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("callback"),
      nnkBracketExpr.newTree(
        newIdentNode("ExecProc"),
        newIdentNode("Thingy")
      ),
      newIdentNode("store")
    )
  ),
  nnkCall.newTree(
    newIdentNode("callback"),
    nnkObjConstr.newTree(
      newIdentNode("Thingy"),
      nnkExprColonExpr.newTree(
        newIdentNode("value"),
        newLit(123)
      )
    )
  )
)
1.4.8 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/temp.nim(7, 1) Error: signature for '=destroy' must be proc[T: object](x: var T)

IR

Compiled filesize 96.89 Kb (99,216 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#define nimfr_(proc, file) \
TFrame FR_; \
FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
#define nimfrs_(proc, file, slots, length) \
 struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename;NI len;VarSlot s[slots];} FR_; \
 FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
#define nimln_(n) \
 FR_.line = n;
#define nimlf_(n, file) \
 FR_.line = n; FR_.filename = file;
typedef struct tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
typedef struct tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag;
typedef struct TNimTypeV2 TNimTypeV2;
typedef struct {
N_NIMCALL_PTR(void, ClP_0) (tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0, void* ClE_0);
void* ClE_0;
} tyProc__57He2SY0oGSpYVIsnenmhw;
struct tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw {
 NI value;
};
struct NimStrPayload {
 NI cap;
 NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
 NI len;
 NimStrPayload* p;
};
typedef NimStringV2 tyArray__nHXaesL0DJZHyVS07ARPRA[1];
typedef N_CLOSURE_PTR(void, TM__SRd76hP9cMfCzdUO857UhQQ_5) (tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0, void* ClE_0);
typedef N_CLOSURE_PTR(void, TM__SRd76hP9cMfCzdUO857UhQQ_6) (tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0);
struct tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag {
 NI rc;
 NI rootIdx;
};
struct TNimTypeV2 {
 void* destructor;
 NI size;
 NI16 align;
 NI16 depth;
 NU32* display;
 void* traceImpl;
 void* typeInfoV1;
 NI flags;
};
N_LIB_PRIVATE N_NIMCALL(void, store__temp_u22)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, dollar___temp_u55)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw x_p0);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringV2* args_p0, NI args_p0Len_0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u11)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw thingy_p0);
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__stdZassertions_u310)(NimStringV2 msg_p0);
N_LIB_PRIVATE N_NOINLINE(void, raiseOverflow)(void);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4607)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
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);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u105)(tyProc__57He2SY0oGSpYVIsnenmhw* dest_p0);
static N_INLINE(NIM_BOOL, nimDecRefIsLastCyclicDyn)(void* p_p0);
static N_INLINE(NI, minuspercent___system_u810)(NI x_p0, NI y_p1);
N_LIB_PRIVATE N_NOINLINE(void, rememberCycle__system_u3403)(NIM_BOOL isDestroyAction_p0, tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag* s_p1, TNimTypeV2* desc_p2);
N_LIB_PRIVATE N_NIMCALL(void, nimDestroyAndDispose)(void* p_p0);
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[68 1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 68 | NIM_STRLIT_FLAG, "/home/runner/work/Nim/Nim/temp.nim(8, 11) `thingyDestroyCount <= 0` " };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {68, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
N_LIB_PRIVATE tyProc__57He2SY0oGSpYVIsnenmhw callback__temp_u101;
N_LIB_PRIVATE NI thingyDestroyCount__temp_u10 = ((NI)0);
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4389;
extern NIM_THREADVAR TFrame* framePtr__system_u4006;
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
 NIM_BOOL* result;
 result = (NIM_BOOL*)0;
 result = (&nimInErrorMode__system_u4389);
 return result;
}
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
 {
  if (!(framePtr__system_u4006 == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s_p0).calldepth = ((NI16)0);
 }
 goto LA1_;
LA3_: ;
 {
  (*s_p0).calldepth = (NI16)((*framePtr__system_u4006).calldepth   ((NI16)1));
 }
LA1_: ;
 (*s_p0).prev = framePtr__system_u4006;
 framePtr__system_u4006 = s_p0;
 {
  if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
  callDepthLimitReached__system_u4607();
 }
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__system_u4006 = (*framePtr__system_u4006).prev;
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u11)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw thingy_p0) {
 NI TM__SRd76hP9cMfCzdUO857UhQQ_4;
NIM_BOOL* nimErr_;
 nimfr_("=destroy", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
 {
  if (!!((thingyDestroyCount__temp_u10 <= ((NI)0)))) goto LA3_;
  failedAssertImpl__stdZassertions_u310(TM__SRd76hP9cMfCzdUO857UhQQ_3);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
LA3_: ;
 if (nimAddInt(thingyDestroyCount__temp_u10, ((NI)1), &TM__SRd76hP9cMfCzdUO857UhQQ_4)) { raiseOverflow(); goto BeforeRet_;
 };
 thingyDestroyCount__temp_u10 = (NI)(TM__SRd76hP9cMfCzdUO857UhQQ_4);
 }BeforeRet_: ;
 popFrame();
}
N_LIB_PRIVATE N_NIMCALL(void, store__temp_u22)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0) {
 NimStringV2 colontmpD_;
 tyArray__nHXaesL0DJZHyVS07ARPRA T2_;
NIM_BOOL oldNimErrFin1_;
NIM_BOOL* nimErr_;
 nimfr_("store", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
 colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
 colontmpD_ = dollar___temp_u55(value_p0);
 if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
 T2_[0] = colontmpD_;
 echoBinSafe(T2_, 1);
 {
  LA1_:;
 }
 {
  oldNimErrFin1_ = *nimErr_; *nimErr_ = NIM_FALSE;
  eqdestroy___temp_u11(value_p0);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
  if (colontmpD_.p && !(colontmpD_.p->cap & NIM_STRLIT_FLAG)) {
deallocShared(colontmpD_.p);
}
  *nimErr_ = oldNimErrFin1_;
 }
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }BeforeRet_: ;
 popFrame();
}
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(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(NI, minuspercent___system_u810)(NI x_p0, NI y_p1) {
 NI result;
 nimfr_("-%", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arithmetics.nim");
 result = (NI)0;
 result = ((NI) ((NU)((NU64)(((NU) (x_p0))) - (NU64)(((NU) (y_p1))))));
 popFrame();
 return result;
}
static N_INLINE(NIM_BOOL, nimDecRefIsLastCyclicDyn)(void* p_p0) {
 NIM_BOOL result;
NIM_BOOL* nimErr_;
 nimfr_("nimDecRefIsLastCyclicDyn", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/orc.nim");
{nimErr_ = nimErrorFlag();
 result = (NIM_BOOL)0;
 {
  tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag* cell;
  NI T5_;
  if (!!((p_p0 == NIM_NIL))) goto LA3_;
  T5_ = (NI)0;
  T5_ = minuspercent___system_u810(((NI) (ptrdiff_t) (p_p0)), ((NI)16));
  cell = ((tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag*) (T5_));
  {
   if (!((NI)((*cell).rc & ((NI)-16)) == ((NI)0))) goto LA8_;
   result = NIM_TRUE;
  }
  goto LA6_;
LA8_: ;
  {
   NI TM__SRd76hP9cMfCzdUO857UhQQ_7;
   if (nimSubInt((*cell).rc, ((NI)16), &TM__SRd76hP9cMfCzdUO857UhQQ_7)) { raiseOverflow(); goto BeforeRet_;
   };
   (*cell).rc = (NI)(TM__SRd76hP9cMfCzdUO857UhQQ_7);
  }
LA6_: ;
  rememberCycle__system_u3403(result, cell, (*((TNimTypeV2**) (p_p0))));
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
LA3_: ;
 }BeforeRet_: ;
 popFrame();
 return result;
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u105)(tyProc__57He2SY0oGSpYVIsnenmhw* dest_p0) {
 {
  NIM_BOOL T3_;
  T3_ = (NIM_BOOL)0;
  T3_ = nimDecRefIsLastCyclicDyn((*dest_p0).ClE_0);
  if (!T3_) goto LA4_;
  nimDestroyAndDispose((*dest_p0).ClE_0);
 }
LA4_: ;
}
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) {
{
 tyProc__57He2SY0oGSpYVIsnenmhw T1_;
 tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw T2_;
NIM_BOOL* nimErr_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
 nimZeroMem((void*)(&T1_), sizeof(tyProc__57He2SY0oGSpYVIsnenmhw));
 T1_.ClP_0 = ((TM__SRd76hP9cMfCzdUO857UhQQ_5) (store__temp_u22)); T1_.ClE_0 = NIM_NIL;
 callback__temp_u101.ClE_0 = T1_.ClE_0;
 callback__temp_u101.ClP_0 = T1_.ClP_0;
 nimZeroMem((void*)(&T2_), sizeof(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw));
 T2_.value = ((NI)123);
 callback__temp_u101.ClE_0? callback__temp_u101.ClP_0(T2_, callback__temp_u101.ClE_0):((TM__SRd76hP9cMfCzdUO857UhQQ_6)(callback__temp_u101.ClP_0))(T2_);
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 eqdestroy___temp_u105((&callback__temp_u101));
 BeforeRet_: ;
 nimTestErrorFlag();
 popFrame();
}
}

Stats

  • Started 2024-07-31T17:55:23
  • Finished 2024-07-31T17:55:23
  • Duration

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("Thingy"),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("value"),
            newIdentNode("int"),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("ExecProc"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("C"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkProcTy.newTree(
        nnkFormalParams.newTree(
          newIdentNode("void"),
          nnkIdentDefs.newTree(
            newIdentNode("value"),
            nnkCommand.newTree(
              newIdentNode("sink"),
              newIdentNode("C")
            ),
            newEmptyNode()
          )
        ),
        newEmptyNode()
      )
    )
  ),
  nnkProcDef.newTree(
    nnkAccQuoted.newTree(
      newIdentNode("="),
      newIdentNode("copy")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkVarTy.newTree(
          newIdentNode("Thingy")
        ),
        newEmptyNode()
      ),
      nnkIdentDefs.newTree(
        newIdentNode("b"),
        newIdentNode("Thingy"),
        newEmptyNode()
      )
    ),
    nnkPragma.newTree(
      newIdentNode("error")
    ),
    newEmptyNode(),
    newEmptyNode()
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("thingyDestroyCount"),
      newEmptyNode(),
      newLit(0)
    )
  ),
  nnkProcDef.newTree(
    nnkAccQuoted.newTree(
      newIdentNode("="),
      newIdentNode("destroy")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("thingy"),
        newIdentNode("Thingy"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        newIdentNode("assert"),
        nnkInfix.newTree(
          newIdentNode("<="),
          newIdentNode("thingyDestroyCount"),
          newLit(0)
        )
      ),
      nnkInfix.newTree(
        newIdentNode(" ="),
        newIdentNode("thingyDestroyCount"),
        newLit(1)
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("store"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("void"),
      nnkIdentDefs.newTree(
        newIdentNode("value"),
        nnkCommand.newTree(
          newIdentNode("sink"),
          newIdentNode("Thingy")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("value")
      )
    )
  ),
  nnkLetSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("callback"),
      nnkBracketExpr.newTree(
        newIdentNode("ExecProc"),
        newIdentNode("Thingy")
      ),
      newIdentNode("store")
    )
  ),
  nnkCall.newTree(
    newIdentNode("callback"),
    nnkObjConstr.newTree(
      newIdentNode("Thingy"),
      nnkExprColonExpr.newTree(
        newIdentNode("value"),
        newLit(123)
      )
    )
  )
)
1.2.18 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/temp.nim(7, 1) Error: signature for '=destroy' must be proc[T: object](x: var T)

IR

Compiled filesize 96.89 Kb (99,216 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#define nimfr_(proc, file) \
TFrame FR_; \
FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
#define nimfrs_(proc, file, slots, length) \
 struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename;NI len;VarSlot s[slots];} FR_; \
 FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
#define nimln_(n) \
 FR_.line = n;
#define nimlf_(n, file) \
 FR_.line = n; FR_.filename = file;
typedef struct tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
typedef struct tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag;
typedef struct TNimTypeV2 TNimTypeV2;
typedef struct {
N_NIMCALL_PTR(void, ClP_0) (tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0, void* ClE_0);
void* ClE_0;
} tyProc__57He2SY0oGSpYVIsnenmhw;
struct tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw {
 NI value;
};
struct NimStrPayload {
 NI cap;
 NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
 NI len;
 NimStrPayload* p;
};
typedef NimStringV2 tyArray__nHXaesL0DJZHyVS07ARPRA[1];
typedef N_CLOSURE_PTR(void, TM__SRd76hP9cMfCzdUO857UhQQ_5) (tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0, void* ClE_0);
typedef N_CLOSURE_PTR(void, TM__SRd76hP9cMfCzdUO857UhQQ_6) (tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0);
struct tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag {
 NI rc;
 NI rootIdx;
};
struct TNimTypeV2 {
 void* destructor;
 NI size;
 NI16 align;
 NI16 depth;
 NU32* display;
 void* traceImpl;
 void* typeInfoV1;
 NI flags;
};
N_LIB_PRIVATE N_NIMCALL(void, store__temp_u22)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, dollar___temp_u55)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw x_p0);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringV2* args_p0, NI args_p0Len_0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u11)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw thingy_p0);
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__stdZassertions_u310)(NimStringV2 msg_p0);
N_LIB_PRIVATE N_NOINLINE(void, raiseOverflow)(void);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4607)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
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);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u105)(tyProc__57He2SY0oGSpYVIsnenmhw* dest_p0);
static N_INLINE(NIM_BOOL, nimDecRefIsLastCyclicDyn)(void* p_p0);
static N_INLINE(NI, minuspercent___system_u810)(NI x_p0, NI y_p1);
N_LIB_PRIVATE N_NOINLINE(void, rememberCycle__system_u3403)(NIM_BOOL isDestroyAction_p0, tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag* s_p1, TNimTypeV2* desc_p2);
N_LIB_PRIVATE N_NIMCALL(void, nimDestroyAndDispose)(void* p_p0);
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[68 1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 68 | NIM_STRLIT_FLAG, "/home/runner/work/Nim/Nim/temp.nim(8, 11) `thingyDestroyCount <= 0` " };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {68, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
N_LIB_PRIVATE tyProc__57He2SY0oGSpYVIsnenmhw callback__temp_u101;
N_LIB_PRIVATE NI thingyDestroyCount__temp_u10 = ((NI)0);
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4389;
extern NIM_THREADVAR TFrame* framePtr__system_u4006;
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
 NIM_BOOL* result;
 result = (NIM_BOOL*)0;
 result = (&nimInErrorMode__system_u4389);
 return result;
}
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
 {
  if (!(framePtr__system_u4006 == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s_p0).calldepth = ((NI16)0);
 }
 goto LA1_;
LA3_: ;
 {
  (*s_p0).calldepth = (NI16)((*framePtr__system_u4006).calldepth   ((NI16)1));
 }
LA1_: ;
 (*s_p0).prev = framePtr__system_u4006;
 framePtr__system_u4006 = s_p0;
 {
  if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
  callDepthLimitReached__system_u4607();
 }
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__system_u4006 = (*framePtr__system_u4006).prev;
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u11)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw thingy_p0) {
 NI TM__SRd76hP9cMfCzdUO857UhQQ_4;
NIM_BOOL* nimErr_;
 nimfr_("=destroy", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
 {
  if (!!((thingyDestroyCount__temp_u10 <= ((NI)0)))) goto LA3_;
  failedAssertImpl__stdZassertions_u310(TM__SRd76hP9cMfCzdUO857UhQQ_3);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
LA3_: ;
 if (nimAddInt(thingyDestroyCount__temp_u10, ((NI)1), &TM__SRd76hP9cMfCzdUO857UhQQ_4)) { raiseOverflow(); goto BeforeRet_;
 };
 thingyDestroyCount__temp_u10 = (NI)(TM__SRd76hP9cMfCzdUO857UhQQ_4);
 }BeforeRet_: ;
 popFrame();
}
N_LIB_PRIVATE N_NIMCALL(void, store__temp_u22)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0) {
 NimStringV2 colontmpD_;
 tyArray__nHXaesL0DJZHyVS07ARPRA T2_;
NIM_BOOL oldNimErrFin1_;
NIM_BOOL* nimErr_;
 nimfr_("store", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
 colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
 colontmpD_ = dollar___temp_u55(value_p0);
 if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
 T2_[0] = colontmpD_;
 echoBinSafe(T2_, 1);
 {
  LA1_:;
 }
 {
  oldNimErrFin1_ = *nimErr_; *nimErr_ = NIM_FALSE;
  eqdestroy___temp_u11(value_p0);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
  if (colontmpD_.p && !(colontmpD_.p->cap & NIM_STRLIT_FLAG)) {
deallocShared(colontmpD_.p);
}
  *nimErr_ = oldNimErrFin1_;
 }
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }BeforeRet_: ;
 popFrame();
}
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(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(NI, minuspercent___system_u810)(NI x_p0, NI y_p1) {
 NI result;
 nimfr_("-%", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arithmetics.nim");
 result = (NI)0;
 result = ((NI) ((NU)((NU64)(((NU) (x_p0))) - (NU64)(((NU) (y_p1))))));
 popFrame();
 return result;
}
static N_INLINE(NIM_BOOL, nimDecRefIsLastCyclicDyn)(void* p_p0) {
 NIM_BOOL result;
NIM_BOOL* nimErr_;
 nimfr_("nimDecRefIsLastCyclicDyn", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/orc.nim");
{nimErr_ = nimErrorFlag();
 result = (NIM_BOOL)0;
 {
  tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag* cell;
  NI T5_;
  if (!!((p_p0 == NIM_NIL))) goto LA3_;
  T5_ = (NI)0;
  T5_ = minuspercent___system_u810(((NI) (ptrdiff_t) (p_p0)), ((NI)16));
  cell = ((tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag*) (T5_));
  {
   if (!((NI)((*cell).rc & ((NI)-16)) == ((NI)0))) goto LA8_;
   result = NIM_TRUE;
  }
  goto LA6_;
LA8_: ;
  {
   NI TM__SRd76hP9cMfCzdUO857UhQQ_7;
   if (nimSubInt((*cell).rc, ((NI)16), &TM__SRd76hP9cMfCzdUO857UhQQ_7)) { raiseOverflow(); goto BeforeRet_;
   };
   (*cell).rc = (NI)(TM__SRd76hP9cMfCzdUO857UhQQ_7);
  }
LA6_: ;
  rememberCycle__system_u3403(result, cell, (*((TNimTypeV2**) (p_p0))));
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
LA3_: ;
 }BeforeRet_: ;
 popFrame();
 return result;
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u105)(tyProc__57He2SY0oGSpYVIsnenmhw* dest_p0) {
 {
  NIM_BOOL T3_;
  T3_ = (NIM_BOOL)0;
  T3_ = nimDecRefIsLastCyclicDyn((*dest_p0).ClE_0);
  if (!T3_) goto LA4_;
  nimDestroyAndDispose((*dest_p0).ClE_0);
 }
LA4_: ;
}
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) {
{
 tyProc__57He2SY0oGSpYVIsnenmhw T1_;
 tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw T2_;
NIM_BOOL* nimErr_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
 nimZeroMem((void*)(&T1_), sizeof(tyProc__57He2SY0oGSpYVIsnenmhw));
 T1_.ClP_0 = ((TM__SRd76hP9cMfCzdUO857UhQQ_5) (store__temp_u22)); T1_.ClE_0 = NIM_NIL;
 callback__temp_u101.ClE_0 = T1_.ClE_0;
 callback__temp_u101.ClP_0 = T1_.ClP_0;
 nimZeroMem((void*)(&T2_), sizeof(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw));
 T2_.value = ((NI)123);
 callback__temp_u101.ClE_0? callback__temp_u101.ClP_0(T2_, callback__temp_u101.ClE_0):((TM__SRd76hP9cMfCzdUO857UhQQ_6)(callback__temp_u101.ClP_0))(T2_);
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 eqdestroy___temp_u105((&callback__temp_u101));
 BeforeRet_: ;
 nimTestErrorFlag();
 popFrame();
}
}

Stats

  • Started 2024-07-31T17:55:25
  • Finished 2024-07-31T17:55:25
  • Duration

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("Thingy"),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("value"),
            newIdentNode("int"),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("ExecProc"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("C"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkProcTy.newTree(
        nnkFormalParams.newTree(
          newIdentNode("void"),
          nnkIdentDefs.newTree(
            newIdentNode("value"),
            nnkCommand.newTree(
              newIdentNode("sink"),
              newIdentNode("C")
            ),
            newEmptyNode()
          )
        ),
        newEmptyNode()
      )
    )
  ),
  nnkProcDef.newTree(
    nnkAccQuoted.newTree(
      newIdentNode("="),
      newIdentNode("copy")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkVarTy.newTree(
          newIdentNode("Thingy")
        ),
        newEmptyNode()
      ),
      nnkIdentDefs.newTree(
        newIdentNode("b"),
        newIdentNode("Thingy"),
        newEmptyNode()
      )
    ),
    nnkPragma.newTree(
      newIdentNode("error")
    ),
    newEmptyNode(),
    newEmptyNode()
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("thingyDestroyCount"),
      newEmptyNode(),
      newLit(0)
    )
  ),
  nnkProcDef.newTree(
    nnkAccQuoted.newTree(
      newIdentNode("="),
      newIdentNode("destroy")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("thingy"),
        newIdentNode("Thingy"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        newIdentNode("assert"),
        nnkInfix.newTree(
          newIdentNode("<="),
          newIdentNode("thingyDestroyCount"),
          newLit(0)
        )
      ),
      nnkInfix.newTree(
        newIdentNode(" ="),
        newIdentNode("thingyDestroyCount"),
        newLit(1)
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("store"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("void"),
      nnkIdentDefs.newTree(
        newIdentNode("value"),
        nnkCommand.newTree(
          newIdentNode("sink"),
          newIdentNode("Thingy")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("value")
      )
    )
  ),
  nnkLetSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("callback"),
      nnkBracketExpr.newTree(
        newIdentNode("ExecProc"),
        newIdentNode("Thingy")
      ),
      newIdentNode("store")
    )
  ),
  nnkCall.newTree(
    newIdentNode("callback"),
    nnkObjConstr.newTree(
      newIdentNode("Thingy"),
      nnkExprColonExpr.newTree(
        newIdentNode("value"),
        newLit(123)
      )
    )
  )
)
1.0.10 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/temp.nim(7, 1) Error: signature for '=destroy' must be proc[T: object](x: var T)

IR

Compiled filesize 96.89 Kb (99,216 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#define nimfr_(proc, file) \
TFrame FR_; \
FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
#define nimfrs_(proc, file, slots, length) \
 struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename;NI len;VarSlot s[slots];} FR_; \
 FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
#define nimln_(n) \
 FR_.line = n;
#define nimlf_(n, file) \
 FR_.line = n; FR_.filename = file;
typedef struct tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
typedef struct tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag;
typedef struct TNimTypeV2 TNimTypeV2;
typedef struct {
N_NIMCALL_PTR(void, ClP_0) (tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0, void* ClE_0);
void* ClE_0;
} tyProc__57He2SY0oGSpYVIsnenmhw;
struct tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw {
 NI value;
};
struct NimStrPayload {
 NI cap;
 NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
 NI len;
 NimStrPayload* p;
};
typedef NimStringV2 tyArray__nHXaesL0DJZHyVS07ARPRA[1];
typedef N_CLOSURE_PTR(void, TM__SRd76hP9cMfCzdUO857UhQQ_5) (tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0, void* ClE_0);
typedef N_CLOSURE_PTR(void, TM__SRd76hP9cMfCzdUO857UhQQ_6) (tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0);
struct tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag {
 NI rc;
 NI rootIdx;
};
struct TNimTypeV2 {
 void* destructor;
 NI size;
 NI16 align;
 NI16 depth;
 NU32* display;
 void* traceImpl;
 void* typeInfoV1;
 NI flags;
};
N_LIB_PRIVATE N_NIMCALL(void, store__temp_u22)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, dollar___temp_u55)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw x_p0);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringV2* args_p0, NI args_p0Len_0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u11)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw thingy_p0);
N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__stdZassertions_u310)(NimStringV2 msg_p0);
N_LIB_PRIVATE N_NOINLINE(void, raiseOverflow)(void);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4607)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
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);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u105)(tyProc__57He2SY0oGSpYVIsnenmhw* dest_p0);
static N_INLINE(NIM_BOOL, nimDecRefIsLastCyclicDyn)(void* p_p0);
static N_INLINE(NI, minuspercent___system_u810)(NI x_p0, NI y_p1);
N_LIB_PRIVATE N_NOINLINE(void, rememberCycle__system_u3403)(NIM_BOOL isDestroyAction_p0, tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag* s_p1, TNimTypeV2* desc_p2);
N_LIB_PRIVATE N_NIMCALL(void, nimDestroyAndDispose)(void* p_p0);
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[68 1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 68 | NIM_STRLIT_FLAG, "/home/runner/work/Nim/Nim/temp.nim(8, 11) `thingyDestroyCount <= 0` " };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {68, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
N_LIB_PRIVATE tyProc__57He2SY0oGSpYVIsnenmhw callback__temp_u101;
N_LIB_PRIVATE NI thingyDestroyCount__temp_u10 = ((NI)0);
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4389;
extern NIM_THREADVAR TFrame* framePtr__system_u4006;
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
 NIM_BOOL* result;
 result = (NIM_BOOL*)0;
 result = (&nimInErrorMode__system_u4389);
 return result;
}
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
 {
  if (!(framePtr__system_u4006 == ((TFrame*) NIM_NIL))) goto LA3_;
  (*s_p0).calldepth = ((NI16)0);
 }
 goto LA1_;
LA3_: ;
 {
  (*s_p0).calldepth = (NI16)((*framePtr__system_u4006).calldepth   ((NI16)1));
 }
LA1_: ;
 (*s_p0).prev = framePtr__system_u4006;
 framePtr__system_u4006 = s_p0;
 {
  if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
  callDepthLimitReached__system_u4607();
 }
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
 framePtr__system_u4006 = (*framePtr__system_u4006).prev;
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u11)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw thingy_p0) {
 NI TM__SRd76hP9cMfCzdUO857UhQQ_4;
NIM_BOOL* nimErr_;
 nimfr_("=destroy", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
 {
  if (!!((thingyDestroyCount__temp_u10 <= ((NI)0)))) goto LA3_;
  failedAssertImpl__stdZassertions_u310(TM__SRd76hP9cMfCzdUO857UhQQ_3);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
LA3_: ;
 if (nimAddInt(thingyDestroyCount__temp_u10, ((NI)1), &TM__SRd76hP9cMfCzdUO857UhQQ_4)) { raiseOverflow(); goto BeforeRet_;
 };
 thingyDestroyCount__temp_u10 = (NI)(TM__SRd76hP9cMfCzdUO857UhQQ_4);
 }BeforeRet_: ;
 popFrame();
}
N_LIB_PRIVATE N_NIMCALL(void, store__temp_u22)(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw value_p0) {
 NimStringV2 colontmpD_;
 tyArray__nHXaesL0DJZHyVS07ARPRA T2_;
NIM_BOOL oldNimErrFin1_;
NIM_BOOL* nimErr_;
 nimfr_("store", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
 colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
 colontmpD_ = dollar___temp_u55(value_p0);
 if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
 T2_[0] = colontmpD_;
 echoBinSafe(T2_, 1);
 {
  LA1_:;
 }
 {
  oldNimErrFin1_ = *nimErr_; *nimErr_ = NIM_FALSE;
  eqdestroy___temp_u11(value_p0);
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
  if (colontmpD_.p && !(colontmpD_.p->cap & NIM_STRLIT_FLAG)) {
deallocShared(colontmpD_.p);
}
  *nimErr_ = oldNimErrFin1_;
 }
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }BeforeRet_: ;
 popFrame();
}
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(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(NI, minuspercent___system_u810)(NI x_p0, NI y_p1) {
 NI result;
 nimfr_("-%", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arithmetics.nim");
 result = (NI)0;
 result = ((NI) ((NU)((NU64)(((NU) (x_p0))) - (NU64)(((NU) (y_p1))))));
 popFrame();
 return result;
}
static N_INLINE(NIM_BOOL, nimDecRefIsLastCyclicDyn)(void* p_p0) {
 NIM_BOOL result;
NIM_BOOL* nimErr_;
 nimfr_("nimDecRefIsLastCyclicDyn", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/orc.nim");
{nimErr_ = nimErrorFlag();
 result = (NIM_BOOL)0;
 {
  tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag* cell;
  NI T5_;
  if (!!((p_p0 == NIM_NIL))) goto LA3_;
  T5_ = (NI)0;
  T5_ = minuspercent___system_u810(((NI) (ptrdiff_t) (p_p0)), ((NI)16));
  cell = ((tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag*) (T5_));
  {
   if (!((NI)((*cell).rc & ((NI)-16)) == ((NI)0))) goto LA8_;
   result = NIM_TRUE;
  }
  goto LA6_;
LA8_: ;
  {
   NI TM__SRd76hP9cMfCzdUO857UhQQ_7;
   if (nimSubInt((*cell).rc, ((NI)16), &TM__SRd76hP9cMfCzdUO857UhQQ_7)) { raiseOverflow(); goto BeforeRet_;
   };
   (*cell).rc = (NI)(TM__SRd76hP9cMfCzdUO857UhQQ_7);
  }
LA6_: ;
  rememberCycle__system_u3403(result, cell, (*((TNimTypeV2**) (p_p0))));
  if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 }
LA3_: ;
 }BeforeRet_: ;
 popFrame();
 return result;
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u105)(tyProc__57He2SY0oGSpYVIsnenmhw* dest_p0) {
 {
  NIM_BOOL T3_;
  T3_ = (NIM_BOOL)0;
  T3_ = nimDecRefIsLastCyclicDyn((*dest_p0).ClE_0);
  if (!T3_) goto LA4_;
  nimDestroyAndDispose((*dest_p0).ClE_0);
 }
LA4_: ;
}
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) {
{
 tyProc__57He2SY0oGSpYVIsnenmhw T1_;
 tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw T2_;
NIM_BOOL* nimErr_;
 nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
 nimZeroMem((void*)(&T1_), sizeof(tyProc__57He2SY0oGSpYVIsnenmhw));
 T1_.ClP_0 = ((TM__SRd76hP9cMfCzdUO857UhQQ_5) (store__temp_u22)); T1_.ClE_0 = NIM_NIL;
 callback__temp_u101.ClE_0 = T1_.ClE_0;
 callback__temp_u101.ClP_0 = T1_.ClP_0;
 nimZeroMem((void*)(&T2_), sizeof(tyObject_Thingy__9bogoebRvrwzpT5DgDIgSvw));
 T2_.value = ((NI)123);
 callback__temp_u101.ClE_0? callback__temp_u101.ClP_0(T2_, callback__temp_u101.ClE_0):((TM__SRd76hP9cMfCzdUO857UhQQ_6)(callback__temp_u101.ClP_0))(T2_);
 if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
 eqdestroy___temp_u105((&callback__temp_u101));
 BeforeRet_: ;
 nimTestErrorFlag();
 popFrame();
}
}

Stats

  • Started 2024-07-31T17:55:28
  • Finished 2024-07-31T17:55:28
  • Duration

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("Thingy"),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("value"),
            newIdentNode("int"),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("ExecProc"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("C"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkProcTy.newTree(
        nnkFormalParams.newTree(
          newIdentNode("void"),
          nnkIdentDefs.newTree(
            newIdentNode("value"),
            nnkCommand.newTree(
              newIdentNode("sink"),
              newIdentNode("C")
            ),
            newEmptyNode()
          )
        ),
        newEmptyNode()
      )
    )
  ),
  nnkProcDef.newTree(
    nnkAccQuoted.newTree(
      newIdentNode("="),
      newIdentNode("copy")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("a"),
        nnkVarTy.newTree(
          newIdentNode("Thingy")
        ),
        newEmptyNode()
      ),
      nnkIdentDefs.newTree(
        newIdentNode("b"),
        newIdentNode("Thingy"),
        newEmptyNode()
      )
    ),
    nnkPragma.newTree(
      newIdentNode("error")
    ),
    newEmptyNode(),
    newEmptyNode()
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("thingyDestroyCount"),
      newEmptyNode(),
      newLit(0)
    )
  ),
  nnkProcDef.newTree(
    nnkAccQuoted.newTree(
      newIdentNode("="),
      newIdentNode("destroy")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("thingy"),
        newIdentNode("Thingy"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        newIdentNode("assert"),
        nnkInfix.newTree(
          newIdentNode("<="),
          newIdentNode("thingyDestroyCount"),
          newLit(0)
        )
      ),
      nnkInfix.newTree(
        newIdentNode(" ="),
        newIdentNode("thingyDestroyCount"),
        newLit(1)
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("store"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("void"),
      nnkIdentDefs.newTree(
        newIdentNode("value"),
        nnkCommand.newTree(
          newIdentNode("sink"),
          newIdentNode("Thingy")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("value")
      )
    )
  ),
  nnkLetSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("callback"),
      nnkBracketExpr.newTree(
        newIdentNode("ExecProc"),
        newIdentNode("Thingy")
      ),
      newIdentNode("store")
    )
  ),
  nnkCall.newTree(
    newIdentNode("callback"),
    nnkObjConstr.newTree(
      newIdentNode("Thingy"),
      nnkExprColonExpr.newTree(
        newIdentNode("value"),
        newLit(123)
      )
    )
  )
)
#b68e0aab4 ➡️ 🐛

Diagnostics

ringabout introduced a bug at 2023-11-02 18:14:50 0800 on commit #b68e0aab4 with message:

fixes #22866; fixes #19998; ensure destruction for Object construction with custom destructors (#22901)

fixes #22866;
fixes #19998

The bug is in the files:

compiler/injectdestructors.nim
tests/arc/tcomputedgoto.nim
tests/arc/tcomputedgotocopy.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-07-31T17:54:35Z
  • Comments 1
  • Commands nim c --run -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

🤖 Bug found in 27 minutes bisecting 747 commits at 27 commits per second

@juancarlospaco
Copy link
Collaborator

@ringabout See #23907 (comment) looks like your PR introduced the bug (?) 🤔

@ringabout ringabout self-assigned this Aug 1, 2024
@ringabout
Copy link
Member

Yeah, but my PR only exposed a pre-existing problem

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

Successfully merging a pull request may close this issue.

3 participants