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

Destructor not called for result when exception is thrown #22672

Closed
PMunch opened this issue Sep 8, 2023 · 7 comments · Fixed by #23267
Closed

Destructor not called for result when exception is thrown #22672

PMunch opened this issue Sep 8, 2023 · 7 comments · Fixed by #23267

Comments

@PMunch
Copy link
Contributor

PMunch commented Sep 8, 2023

Description

Working further on my MAPM bindings I discovered that throwing exceptions while using result caused ARC to not create a destroy call for result. My smallest repro currently:

import system/ansi_c

type
  MyError = object of CatchableError
  MyObj = object
    internal: pointer

proc `=destroy`(x: MyObj) =
  if x.internal.isNil: return
  x.internal.c_free

proc `=copy`(x: var MyObj, y: MyObj) =
  if x.internal != y.internal:
    x.internal.c_free
    x.internal = y.internal

proc initMyObj(x: string): MyObj =
  result = MyObj(internal: c_malloc(126))
  if x.len < 128:
    result.internal.copyMem(x[0].addr, x.len)
  else:
    raise newException(MyError, "This is an error")

import strutils

try:
  echo initMyObj("Hello world")
  echo initMyObj("Hello world".repeat(128))
except MyError as e:
  echo "Got an error!"
  echo e.msg

Nim Version

v2.0.0 and devel

Current Output

From --expandArc:initMyObj:

result = MyObj(internal: c_malloc(126'u))
if len(x) < 128:
  copyMem(result.internal, addr(x[0]), chckRange(len(x), 0, 9223372036854775807))
else:
  raise
    (ref MyError)(msg: "This is an error", parent: nil)

Confirmed with valgrind --leak-check=full that it does in fact leak:

==1808387== 126 bytes in 1 blocks are definitely lost in loss record 1 of 2
==1808387==    at 0x4841848: malloc (vg_replace_malloc.c:431)
==1808387==    by 0x10E773: initMyObj__test_u10 (test.nim:18)
==1808387==    by 0x10E9DD: NimMainModule (test.nim:28)
==1808387==    by 0x109171: NimMainInner (typedthreads.nim:269)
==1808387==    by 0x109171: NimMain (typedthreads.nim:280)
==1808387==    by 0x109171: main (typedthreads.nim:288)

Expected Output

Based on the output of replacing result with a variable and returning it at the end of the function:

var res
try:
  res = MyObj(internal: c_malloc(126'u))
  if len(x) < 128:
    copyMem(res.internal, addr(x[0]), chckRange(len(x), 0, 9223372036854775807))
  else:
    raise
      (ref MyError)(msg: "This is an error", parent: nil)
  return
    result = res
    `=wasMoved`(res)
finally:
  `=destroy`(res)

Possible Solution

No response

Additional Information

No response

@PMunch
Copy link
Contributor Author

PMunch commented Sep 8, 2023

Removing the line which causes the exception makes Valgrind run clean, same for using a variable to store the result and explicitly returning it.

@juancarlospaco
Copy link
Collaborator

!nim c --gc:arc -d:useMalloc --expandArc:initMyObj

import system/ansi_c

type
  MyError = object of CatchableError
  MyObj = object
    internal: pointer

proc `=destroy`(x: MyObj) =
  if x.internal.isNil: return
  x.internal.c_free

proc `=copy`(x: var MyObj, y: MyObj) =
  if x.internal != y.internal:
    x.internal.c_free
    x.internal = y.internal

proc initMyObj(x: string): MyObj =
  result = MyObj(internal: c_malloc(126))
  if x.len < 128:
    result.internal.copyMem(x[0].addr, x.len)
  else:
    raise newException(MyError, "This is an error")

import strutils

try:
  echo initMyObj("Hello world")
  echo initMyObj("Hello world".repeat(128))
except MyError as e:
  echo "Got an error!"
  echo e.msg

@github-actions
Copy link
Contributor

github-actions bot commented Sep 8, 2023

@juancarlospaco (collaborator)

devel 👍 $\color{green}\textbf{\large OK}$

Output

--expandArc: initMyObj

result = MyObj(internal: c_malloc(126'u))
if len(x) < 128:
  copyMem(result.internal, addr(x[0]), chckRange(len(x), 0, 9223372036854775807))
else:
  raise
    (ref MyError)(msg: "This is an error", parent: nil)
-- end of expandArc ------------------------
(internal: ...)
Got an error!
This is an error

Stats

  • Started 2023-09-08T13:29:37
  • Finished 2023-09-08T13:29:40
  • Duration 2 minutes
stable 👍 $\color{green}\textbf{\large OK}$

Output

--expandArc: initMyObj

result = MyObj(internal: c_malloc(126'u))
if len(x) < 128:
  copyMem(result.internal, addr(x[0]), chckRange(len(x), 0, 9223372036854775807))
else:
  raise
    (ref MyError)(msg: "This is an error", parent: nil)
-- end of expandArc ------------------------
(internal: ...)
Got an error!
This is an error

Stats

  • Started 2023-09-08T13:29:40
  • Finished 2023-09-08T13:29:42
  • Duration 2 minutes
2.0.0 👍 $\color{green}\textbf{\large OK}$

Output

--expandArc: initMyObj

result = MyObj(internal: c_malloc(126'u))
if len(x) < 128:
  copyMem(result.internal, addr(x[0]), chckRange(len(x), 0, 9223372036854775807))
else:
  raise
    (ref MyError)(msg: "This is an error", parent: nil)
-- end of expandArc ------------------------
(internal: ...)
Got an error!
This is an error

Stats

  • Started 2023-09-08T13:29:42
  • Finished 2023-09-08T13:29:45
  • Duration 2 minutes
1.6.0 👎 FAIL

Output

Error: Command failed: nim c --gc:arc -d:useMalloc --expandArc:initMyObj -d:nimArcDebug -d:nimArcIds  -d:nimAllocPagesViaMalloc -d:useSysAssert -d:useGcAssert -d:nimLeakDetector --debugger:native --debuginfo:on  -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim && valgrind /home/runner/work/Nim/Nim/temp
/home/runner/work/Nim/Nim/temp.nim(6, 1) Error: signature for '=destroy' must be proc[T: object](x: var T)

Stats

  • Started 2023-09-08T13:29:48
  • Finished 2023-09-08T13:29:48
  • Duration

IR

Compiled filesize 353.13 Kb (361,600 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
#define nimfr_(proc, file) \
  TFrame FR_; \
  FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
  #define nimfrs_(proc, file, slots, length) \
    struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename;NI len;VarSlot s[slots];} FR_; \
    FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
  #define nimln_(n) \
    FR_.line = n;
  #define nimlf_(n, file) \
    FR_.line = n; FR_.filename = file;
typedef struct tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
typedef struct tyObject_MyError__fVAoPZxkmyx7potpEdBUTw tyObject_MyError__fVAoPZxkmyx7potpEdBUTw;
typedef struct tyObject_CatchableError__plmui9cLQDf1IsFzhQAAHyg tyObject_CatchableError__plmui9cLQDf1IsFzhQAAHyg;
typedef struct Exception Exception;
typedef struct RootObj RootObj;
typedef struct TNimTypeV2 TNimTypeV2;
typedef struct tySequence__2ALwPJKv8Nz8mMm4Hy9crdw tySequence__2ALwPJKv8Nz8mMm4Hy9crdw;
typedef struct tySequence__2ALwPJKv8Nz8mMm4Hy9crdw_Content tySequence__2ALwPJKv8Nz8mMm4Hy9crdw_Content;
typedef struct tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag;
typedef struct tyObject_StackTraceEntry__nOjYJiLBbFH64nNmW1UArA tyObject_StackTraceEntry__nOjYJiLBbFH64nNmW1UArA;
struct tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw {	void* internal;
};
struct NimStrPayload {	NI cap;
	NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {	NI len;
	NimStrPayload* p;
};
typedef NimStringV2 tyArray__nHXaesL0DJZHyVS07ARPRA[1];
struct TNimTypeV2 {	void* destructor;
	NI size;
	NI16 align;
	NI16 depth;
	NU32* display;
	NCSTRING name;
	void* traceImpl;
	void* typeInfoV1;
	NI flags;
};
struct RootObj {TNimTypeV2* m_type;};
struct tySequence__2ALwPJKv8Nz8mMm4Hy9crdw {
  NI len; tySequence__2ALwPJKv8Nz8mMm4Hy9crdw_Content* p;
};
struct Exception {  RootObj Sup;	Exception* parent;
	NCSTRING name;
	NimStringV2 message;
	tySequence__2ALwPJKv8Nz8mMm4Hy9crdw trace;
	Exception* up;
};
struct tyObject_CatchableError__plmui9cLQDf1IsFzhQAAHyg {  Exception Sup;};
struct tyObject_MyError__fVAoPZxkmyx7potpEdBUTw {  tyObject_CatchableError__plmui9cLQDf1IsFzhQAAHyg Sup;};
struct tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag {	NI rc;
	NI refId;
};
struct tyObject_StackTraceEntry__nOjYJiLBbFH64nNmW1UArA {	NCSTRING procname;
	NI line;
	NCSTRING filename;
};
struct tySequence__2ALwPJKv8Nz8mMm4Hy9crdw_Content { NI cap; tyObject_StackTraceEntry__nOjYJiLBbFH64nNmW1UArA data[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(NimStringV2, dollar___temp_u92)(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw x_p0);
N_LIB_PRIVATE N_NIMCALL(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw, initMyObj__temp_u10)(NimStringV2 x_p0);
static N_INLINE(void, copyMem__system_u1745)(void* dest_p0, void* source_p1, NI size_p2);
static N_INLINE(void, nimCopyMem)(void* dest_p0, void* source_p1, NI size_p2);
N_LIB_PRIVATE N_NOINLINE(void, raiseIndexError2)(NI i_p0, NI n_p1);
N_LIB_PRIVATE N_NOINLINE(void, raiseRangeErrorI)(NI64 i_p0, NI64 a_p1, NI64 b_p2);
N_LIB_PRIVATE N_NIMCALL(void*, nimNewObj)(NI size_p0, NI alignment_p1);
N_LIB_PRIVATE N_NIMCALL(void, rttiDestroy__temp_u127)(void* dest_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u27)(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* dest_p0);
static N_INLINE(NIM_BOOL, nimDecRefIsLast)(void* p_p0);
static N_INLINE(NI, minuspercent___system_u810)(NI x_p0, NI y_p1);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4156)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, writeStackTrace__system_u2550)(void);
N_LIB_PRIVATE N_NOINLINE(void, raiseOverflow)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimDestroyAndDispose)(void* p_p0);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___stdZassertions_u82)(tySequence__2ALwPJKv8Nz8mMm4Hy9crdw dest_p0);
N_LIB_PRIVATE N_NIMCALL(void, raiseExceptionEx)(Exception* e_p0, NCSTRING ename_p1, NCSTRING procname_p2, NCSTRING filename_p3, NI line_p4);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringV2* args_p0, NI args_p0Len_0);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, nsuRepeatStr)(NimStringV2 s_p0, NI n_p1);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u5)(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw x_p0);
static N_INLINE(NIM_BOOL, isObjDisplayCheck)(TNimTypeV2* source_p0, NI16 targetDepth_p1, NU32 token_p2);
static N_INLINE(Exception*, nimBorrowCurrentException)(void);
static N_INLINE(Exception*, getCurrentException)(void);
N_LIB_PRIVATE N_NIMCALL(void, eqcopy___stdZtypedthreads_u195)(Exception** dest_p0, Exception* src_p1);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u55)(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* dest_p0);
static N_INLINE(void, popCurrentException)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
N_LIB_PRIVATE TNimTypeV2 NTIv2__fVAoPZxkmyx7potpEdBUTw_;
static const struct {
  NI cap; NIM_CHAR data[16+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_4 = { 16 | NIM_STRLIT_FLAG, "This is an error" };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_5 = {16, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_4};
static const struct {
  NI cap; NIM_CHAR data[11+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_6 = { 11 | NIM_STRLIT_FLAG, "Hello world" };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_7 = {11, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_6};
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_8 = {11, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_6};
static const struct {
  NI cap; NIM_CHAR data[13+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_10 = { 13 | NIM_STRLIT_FLAG, "Got an error!" };
static NIM_CONST tyArray__nHXaesL0DJZHyVS07ARPRA TM__SRd76hP9cMfCzdUO857UhQQ_9 = {{13, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_10}}
;
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u3964;
extern NIM_THREADVAR TFrame* framePtr__system_u3602;
static NIM_CONST NU32 TM__SRd76hP9cMfCzdUO857UhQQ_3[4] = {3701606400, 1285336064, 1504611072, 1344814336};
N_LIB_PRIVATE TNimTypeV2 NTIv2__fVAoPZxkmyx7potpEdBUTw_ = {.destructor = (void*)rttiDestroy__temp_u127, .size = sizeof(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw), .align = (NI16) NIM_ALIGNOF(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw), .depth = 3, .display = TM__SRd76hP9cMfCzdUO857UhQQ_3, .traceImpl = (void*)NIM_NIL, .flags = 0};
extern NIM_THREADVAR Exception* currException__system_u3604;
#line 19 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/memory.nim"
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2) {	void* T1_;
#line 21
	T1_ = (void*)0;	T1_ = memset(a_p0, v_p1, ((size_t) (size_p2)));}
#line 423 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/excpt.nim"
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {	NIM_BOOL* result;	result = (NIM_BOOL*)0;
#line 424
	result = (&nimInErrorMode__system_u3964);	return result;}
#line 30 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/memory.nim"
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1) {NIM_BOOL* nimErr_;{nimErr_ = nimErrorFlag();
#line 31
	nimSetMem__systemZmemory_u7(p_p0, ((int)0), size_p1);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;	}BeforeRet_: ;
}
#line 8 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/memory.nim"
static N_INLINE(void, nimCopyMem)(void* dest_p0, void* source_p1, NI size_p2) {	void* T1_;
#line 10
	T1_ = (void*)0;	T1_ = memcpy(dest_p0, source_p1, ((size_t) (size_p2)));}
#line 2016 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim"
static N_INLINE(void, copyMem__system_u1745)(void* dest_p0, void* source_p1, NI size_p2) {
#line 2017
	nimCopyMem(dest_p0, source_p1, size_p2);
}
#line 549 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/excpt.nim"
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
#line 550
	{		if (!(framePtr__system_u3602 == ((TFrame*) NIM_NIL))) goto LA3_;
#line 551
		(*s_p0).calldepth = ((NI16)0);	}
	goto LA1_;
LA3_: ;
	{
#line 554
		(*s_p0).calldepth = (NI16)((*framePtr__system_u3602).calldepth + ((NI16)1));	}
LA1_: ;
#line 556
	(*s_p0).prev = framePtr__system_u3602;
#line 557
	framePtr__system_u3602 = s_p0;
#line 558
	{		if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
		callDepthLimitReached__system_u4156();
	}
LA8_: ;
}
#line 99 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/excpt.nim"
static N_INLINE(void, popFrame)(void) {
#line 100
	framePtr__system_u3602 = (*framePtr__system_u3602).prev;}
#line 363 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arithmetics.nim"
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;
#line 364
#line 368
	result = ((NI) ((NU)((NU64)(((NU) (x_p0))) - (NU64)(((NU) (y_p1))))));	popFrame();	return result;}
#line 196 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arc.nim"
static N_INLINE(NIM_BOOL, nimDecRefIsLast)(void* p_p0) {	NIM_BOOL result;	nimfr_("nimDecRefIsLast", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arc.nim");{	result = (NIM_BOOL)0;
#line 197
	{		
#line 202
int colontmpD_;		
#line 198
tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag* cell;		NI T5_;		if (!!((p_p0 == NIM_NIL))) goto LA3_;
		colontmpD_ = (int)0;
#line 43
		T5_ = (NI)0;		T5_ = minuspercent___system_u810(((NI) (ptrdiff_t) (p_p0)), ((NI)16));		cell = ((tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag*) (T5_));
#line 201
		{			if (!((*cell).refId == ((NI)20))) goto LA8_;
#line 202
			writeStackTrace__system_u2550();
#line 203
			colontmpD_ = fprintf(stderr, "[DecRef] %p %ld\012", p_p0, (NI)((NI64)((*cell).rc) >> (NU64)(((NI)3))));		}
LA8_: ;
#line 205
		{			if (!((NI)((NI64)((*cell).rc) >> (NU64)(((NI)3))) == ((NI)0))) goto LA12_;
#line 206
			result = NIM_TRUE;		}
		goto LA10_;
LA12_: ;
		{			NI TM__SRd76hP9cMfCzdUO857UhQQ_2;
#line 210
			if (nimSubInt((*cell).rc, ((NI)8), &TM__SRd76hP9cMfCzdUO857UhQQ_2)) { raiseOverflow(); goto BeforeRet_;			};			(*cell).rc = (NI)(TM__SRd76hP9cMfCzdUO857UhQQ_2);		}
LA10_: ;
	}
LA3_: ;
	}BeforeRet_: ;
	popFrame();	return result;}
#line 18 "/home/runner/work/Nim/Nim/temp.nim"
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u27)(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* dest_p0) {	{		NIM_BOOL T3_;		T3_ = (NIM_BOOL)0;		T3_ = nimDecRefIsLast((*dest_p0).Sup.Sup.parent);		if (!T3_) goto LA4_;
		nimDestroyAndDispose((*dest_p0).Sup.Sup.parent);
	}
LA4_: ;
	if ((*dest_p0).Sup.Sup.message.p && !((*dest_p0).Sup.Sup.message.p->cap & NIM_STRLIT_FLAG)) { deallocShared((*dest_p0).Sup.Sup.message.p);}	eqdestroy___stdZassertions_u82((*dest_p0).Sup.Sup.trace);
	{		NIM_BOOL T8_;		T8_ = (NIM_BOOL)0;		T8_ = nimDecRefIsLast((*dest_p0).Sup.Sup.up);		if (!T8_) goto LA9_;
		nimDestroyAndDispose((*dest_p0).Sup.Sup.up);
	}
LA9_: ;
}
#line 18 "/home/runner/work/Nim/Nim/temp.nim"
N_LIB_PRIVATE N_NIMCALL(void, rttiDestroy__temp_u127)(void* dest_p0) {NIM_BOOL* nimErr_;{nimErr_ = nimErrorFlag();	eqdestroy___temp_u27(((tyObject_MyError__fVAoPZxkmyx7potpEdBUTw*) (dest_p0)));
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;	}BeforeRet_: ;
}
#line 13 "/home/runner/work/Nim/Nim/temp.nim"
N_LIB_PRIVATE N_NIMCALL(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw, initMyObj__temp_u10)(NimStringV2 x_p0) {	tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw result;	nimfr_("initMyObj", "/home/runner/work/Nim/Nim/temp.nim");{	nimZeroMem((void*)(&result), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));
#line 14
	nimZeroMem((void*)(&result), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));	result.internal = malloc(((size_t)126));
#line 15
	{		if (!(x_p0.len < ((NI)128))) goto LA3_;
#line 16
		if (((NI)0) < 0 || ((NI)0) >= x_p0.len){ raiseIndexError2(((NI)0),x_p0.len-1); goto BeforeRet_;		}		if ((x_p0.len) < ((NI)0) || (x_p0.len) > ((NI)IL64(9223372036854775807))){ raiseRangeErrorI(x_p0.len, ((NI)0), ((NI)IL64(9223372036854775807))); goto BeforeRet_;		}		copyMem__system_u1745(result.internal, ((void*) ((&x_p0.p->data[((NI)0)]))), ((NI) (x_p0.len)));
	}
	goto LA1_;
LA3_: ;
	{		tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* T6_;		T6_ = NIM_NIL;		T6_ = (tyObject_MyError__fVAoPZxkmyx7potpEdBUTw*) nimNewObj(sizeof(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw), NIM_ALIGNOF(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw));		(*T6_).Sup.Sup.Sup.m_type = (&NTIv2__fVAoPZxkmyx7potpEdBUTw_);		(*T6_).Sup.Sup.name = "MyError";		(*T6_).Sup.Sup.message = TM__SRd76hP9cMfCzdUO857UhQQ_5;		(*T6_).Sup.Sup.parent = ((Exception*) NIM_NIL);
#line 18
		raiseExceptionEx((Exception*)T6_, "MyError", "initMyObj", "/home/runner/work/Nim/Nim/temp.nim", 18);goto BeforeRet_;	}
LA1_: ;
	}BeforeRet_: ;
	popFrame();	return result;}
#line 6 "/home/runner/work/Nim/Nim/temp.nim"
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u5)(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw x_p0) {	nimfr_("=destroy", "/home/runner/work/Nim/Nim/temp.nim");{
#line 7
	{		if (!(x_p0.internal == 0)) goto LA3_;
		goto BeforeRet_;
	}
LA3_: ;
#line 8
	free(x_p0.internal);
	}BeforeRet_: ;
	popFrame();}
#line 237 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arc.nim"
static N_INLINE(NIM_BOOL, isObjDisplayCheck)(TNimTypeV2* source_p0, NI16 targetDepth_p1, NU32 token_p2) {	NIM_BOOL result;	NIM_BOOL T1_;	nimfr_("isObjDisplayCheck", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arc.nim");	result = (NIM_BOOL)0;
#line 238
	T1_ = (NIM_BOOL)0;	T1_ = (targetDepth_p1 <= (*source_p0).depth);	if (!(T1_)) goto LA2_;
	T1_ = ((*source_p0).display[targetDepth_p1] == token_p2);LA2_: ;
	result = T1_;	popFrame();	return result;}
#line 2209 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim"
static N_INLINE(Exception*, nimBorrowCurrentException)(void) {	Exception* result;	nimfr_("nimBorrowCurrentException", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim");	result = NIM_NIL;
#line 2212
	result = currException__system_u3604;	popFrame();	return result;}
#line 2205 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim"
static N_INLINE(Exception*, getCurrentException)(void) {	Exception* result;	nimfr_("getCurrentException", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim");	result = NIM_NIL;
#line 247 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/std/typedthreads.nim"
	eqcopy___stdZtypedthreads_u195(&result, currException__system_u3604);
	popFrame();	return result;}
#line 18 "/home/runner/work/Nim/Nim/temp.nim"
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u55)(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* dest_p0) {	{		NIM_BOOL T3_;		T3_ = (NIM_BOOL)0;		T3_ = nimDecRefIsLast(dest_p0);		if (!T3_) goto LA4_;
		nimDestroyAndDispose(dest_p0);
	}
LA4_: ;
}
#line 137 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/excpt.nim"
static N_INLINE(void, popCurrentException)(void) {
#line 247 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/std/typedthreads.nim"
	eqcopy___stdZtypedthreads_u195(&currException__system_u3604, (*currException__system_u3604).up);
}
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) {
#line 999999 "generated_not_to_break_here"
{
#line 21 "/home/runner/work/Nim/Nim/temp.nim"
tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw colontmpD_;	NimStringV2 colontmpD__2;	
#line 22
NimStringV2 colontmpD__3;	tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw colontmpD__4;	NimStringV2 colontmpD__5;	tyArray__nHXaesL0DJZHyVS07ARPRA T3_;	tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw T4_;	NimStringV2 T5_;	tyArray__nHXaesL0DJZHyVS07ARPRA T6_;	NimStringV2 T7_;	tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw T8_;	NimStringV2 T9_;NIM_BOOL oldNimErrFin2_;NIM_BOOL oldNimErrFin15_;NIM_BOOL* nimErr_;	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");nimErr_ = nimErrorFlag();	nimZeroMem((void*)(&colontmpD_), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));	colontmpD__2.len = 0; colontmpD__2.p = NIM_NIL;	colontmpD__3.len = 0; colontmpD__3.p = NIM_NIL;	nimZeroMem((void*)(&colontmpD__4), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));	colontmpD__5.len = 0; colontmpD__5.p = NIM_NIL;
#line 21
	nimZeroMem((void*)(&T4_), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));	T4_ = initMyObj__temp_u10(TM__SRd76hP9cMfCzdUO857UhQQ_7);	if (NIM_UNLIKELY(*nimErr_)) goto LA2_;	colontmpD_ = T4_;	T5_.len = 0; T5_.p = NIM_NIL;	T5_ = dollar___temp_u92(colontmpD_);	if (NIM_UNLIKELY(*nimErr_)) goto LA2_;	colontmpD__2 = T5_;	T3_[0] = colontmpD__2;	echoBinSafe(T3_, 1);
#line 22
	T7_.len = 0; T7_.p = NIM_NIL;	T7_ = nsuRepeatStr(TM__SRd76hP9cMfCzdUO857UhQQ_8, ((NI)128));	if (NIM_UNLIKELY(*nimErr_)) goto LA2_;	colontmpD__3 = T7_;	nimZeroMem((void*)(&T8_), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));	T8_ = initMyObj__temp_u10(colontmpD__3);	if (NIM_UNLIKELY(*nimErr_)) goto LA2_;	colontmpD__4 = T8_;	T9_.len = 0; T9_.p = NIM_NIL;	T9_ = dollar___temp_u92(colontmpD__4);	if (NIM_UNLIKELY(*nimErr_)) goto LA2_;	colontmpD__5 = T9_;	T6_[0] = colontmpD__5;	echoBinSafe(T6_, 1);	{		LA2_:;	}
	{		oldNimErrFin2_ = *nimErr_; *nimErr_ = NIM_FALSE;
#line 370 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim"
		if (colontmpD__5.p && !(colontmpD__5.p->cap & NIM_STRLIT_FLAG)) { deallocShared(colontmpD__5.p);}
#line 6 "/home/runner/work/Nim/Nim/temp.nim"
		eqdestroy___temp_u5(colontmpD__4);
		if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
#line 370 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim"
		if (colontmpD__3.p && !(colontmpD__3.p->cap & NIM_STRLIT_FLAG)) { deallocShared(colontmpD__3.p);}		if (colontmpD__2.p && !(colontmpD__2.p->cap & NIM_STRLIT_FLAG)) { deallocShared(colontmpD__2.p);}
#line 6 "/home/runner/work/Nim/Nim/temp.nim"
		eqdestroy___temp_u5(colontmpD_);
		if (NIM_UNLIKELY(*nimErr_)) goto LA1_;		*nimErr_ = oldNimErrFin2_;	}
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;	if (NIM_UNLIKELY(*nimErr_)) {		LA1_:;		if (isObjDisplayCheck(nimBorrowCurrentException()->Sup.m_type, 3, 1344814336)) {			
#line 23
tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* e;			Exception* T16_;			tyArray__nHXaesL0DJZHyVS07ARPRA T17_;			*nimErr_ = NIM_FALSE;			e = NIM_NIL;
#line 24
			T16_ = NIM_NIL;			T16_ = getCurrentException();			e = ((tyObject_MyError__fVAoPZxkmyx7potpEdBUTw*) (T16_));
#line 24 "/home/runner/work/Nim/Nim/temp.nim"
			echoBinSafe(TM__SRd76hP9cMfCzdUO857UhQQ_9, 1);
#line 25
			T17_[0] = (*e).Sup.Sup.message;			echoBinSafe(T17_, 1);			{				LA15_:;			}
			{				oldNimErrFin15_ = *nimErr_; *nimErr_ = NIM_FALSE;
#line 18
				eqdestroy___temp_u55(e);
				if (NIM_UNLIKELY(*nimErr_)) goto LA13_;				*nimErr_ = oldNimErrFin15_;			}
			if (NIM_UNLIKELY(*nimErr_)) goto LA13_;			popCurrentException();			LA13_:;		}
	}
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;	BeforeRet_: ;
	nimTestErrorFlag();	popFrame();}
}

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("system"),
      newIdentNode("ansi_c")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("MyError"),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        nnkOfInherit.newTree(
          newIdentNode("CatchableError")
        ),
        newEmptyNode()
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("MyObj"),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("internal"),
            newIdentNode("pointer"),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    nnkAccQuoted.newTree(
      newIdentNode("="),
      newIdentNode("destroy")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("MyObj"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkIfStmt.newTree(
        nnkElifBranch.newTree(
          nnkDotExpr.newTree(
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("internal")
            ),
            newIdentNode("isNil")
          ),
          nnkStmtList.newTree(
            nnkReturnStmt.newTree(
              newEmptyNode()
            )
          )
        )
      ),
      nnkDotExpr.newTree(
        nnkDotExpr.newTree(
          newIdentNode("x"),
          newIdentNode("internal")
        ),
        newIdentNode("c_free")
      )
    )
  ),
  nnkProcDef.newTree(
    nnkAccQuoted.newTree(
      newIdentNode("="),
      newIdentNode("copy")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkVarTy.newTree(
          newIdentNode("MyObj")
        ),
        newEmptyNode()
      ),
      nnkIdentDefs.newTree(
        newIdentNode("y"),
        newIdentNode("MyObj"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkIfStmt.newTree(
        nnkElifBranch.newTree(
          nnkInfix.newTree(
            newIdentNode("!="),
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("internal")
            ),
            nnkDotExpr.newTree(
              newIdentNode("y"),
              newIdentNode("internal")
            )
          ),
          nnkStmtList.newTree(
            nnkDotExpr.newTree(
              nnkDotExpr.newTree(
                newIdentNode("x"),
                newIdentNode("internal")
              ),
              newIdentNode("c_free")
            ),
            nnkAsgn.newTree(
              nnkDotExpr.newTree(
                newIdentNode("x"),
                newIdentNode("internal")
              ),
              nnkDotExpr.newTree(
                newIdentNode("y"),
                newIdentNode("internal")
              )
            )
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("initMyObj"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("MyObj"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("string"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkAsgn.newTree(
        newIdentNode("result"),
        nnkObjConstr.newTree(
          newIdentNode("MyObj"),
          nnkExprColonExpr.newTree(
            newIdentNode("internal"),
            nnkCall.newTree(
              newIdentNode("c_malloc"),
              newLit(126)
            )
          )
        )
      ),
      nnkIfStmt.newTree(
        nnkElifBranch.newTree(
          nnkInfix.newTree(
            newIdentNode("<"),
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("len")
            ),
            newLit(128)
          ),
          nnkStmtList.newTree(
            nnkCall.newTree(
              nnkDotExpr.newTree(
                nnkDotExpr.newTree(
                  newIdentNode("result"),
                  newIdentNode("internal")
                ),
                newIdentNode("copyMem")
              ),
              nnkDotExpr.newTree(
                nnkBracketExpr.newTree(
                  newIdentNode("x"),
                  newLit(0)
                ),
                newIdentNode("addr")
              ),
              nnkDotExpr.newTree(
                newIdentNode("x"),
                newIdentNode("len")
              )
            )
          )
        ),
        nnkElse.newTree(
          nnkStmtList.newTree(
            nnkRaiseStmt.newTree(
              nnkCall.newTree(
                newIdentNode("newException"),
                newIdentNode("MyError"),
                newLit("This is an error")
              )
            )
          )
        )
      )
    )
  ),
  nnkImportStmt.newTree(
    newIdentNode("strutils")
  ),
  nnkTryStmt.newTree(
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        nnkCall.newTree(
          newIdentNode("initMyObj"),
          newLit("Hello world")
        )
      ),
      nnkCommand.newTree(
        newIdentNode("echo"),
        nnkCall.newTree(
          newIdentNode("initMyObj"),
          nnkCall.newTree(
            nnkDotExpr.newTree(
              newLit("Hello world"),
              newIdentNode("repeat")
            ),
            newLit(128)
          )
        )
      )
    ),
    nnkExceptBranch.newTree(
      nnkInfix.newTree(
        newIdentNode("as"),
        newIdentNode("MyError"),
        newIdentNode("e")
      ),
      nnkStmtList.newTree(
        nnkCommand.newTree(
          newIdentNode("echo"),
          newLit("Got an error!")
        ),
        nnkCommand.newTree(
          newIdentNode("echo"),
          nnkDotExpr.newTree(
            newIdentNode("e"),
            newIdentNode("msg")
          )
        )
      )
    )
  )
)
1.4.0 👎 FAIL

Output

Error: Command failed: nim c --gc:arc -d:useMalloc --expandArc:initMyObj -d:nimArcDebug -d:nimArcIds  -d:nimAllocPagesViaMalloc -d:useSysAssert -d:useGcAssert -d:nimLeakDetector --debugger:native --debuginfo:on  -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim && valgrind /home/runner/work/Nim/Nim/temp
/home/runner/work/Nim/Nim/temp.nim(6, 1) Error: signature for '=destroy' must be proc[T: object](x: var T)

Stats

  • Started 2023-09-08T13:29:53
  • Finished 2023-09-08T13:29:53
  • Duration

IR

Compiled filesize 353.13 Kb (361,600 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
#define nimfr_(proc, file) \
  TFrame FR_; \
  FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
  #define nimfrs_(proc, file, slots, length) \
    struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename;NI len;VarSlot s[slots];} FR_; \
    FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
  #define nimln_(n) \
    FR_.line = n;
  #define nimlf_(n, file) \
    FR_.line = n; FR_.filename = file;
typedef struct tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
typedef struct tyObject_MyError__fVAoPZxkmyx7potpEdBUTw tyObject_MyError__fVAoPZxkmyx7potpEdBUTw;
typedef struct tyObject_CatchableError__plmui9cLQDf1IsFzhQAAHyg tyObject_CatchableError__plmui9cLQDf1IsFzhQAAHyg;
typedef struct Exception Exception;
typedef struct RootObj RootObj;
typedef struct TNimTypeV2 TNimTypeV2;
typedef struct tySequence__2ALwPJKv8Nz8mMm4Hy9crdw tySequence__2ALwPJKv8Nz8mMm4Hy9crdw;
typedef struct tySequence__2ALwPJKv8Nz8mMm4Hy9crdw_Content tySequence__2ALwPJKv8Nz8mMm4Hy9crdw_Content;
typedef struct tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag;
typedef struct tyObject_StackTraceEntry__nOjYJiLBbFH64nNmW1UArA tyObject_StackTraceEntry__nOjYJiLBbFH64nNmW1UArA;
struct tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw {	void* internal;
};
struct NimStrPayload {	NI cap;
	NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {	NI len;
	NimStrPayload* p;
};
typedef NimStringV2 tyArray__nHXaesL0DJZHyVS07ARPRA[1];
struct TNimTypeV2 {	void* destructor;
	NI size;
	NI16 align;
	NI16 depth;
	NU32* display;
	NCSTRING name;
	void* traceImpl;
	void* typeInfoV1;
	NI flags;
};
struct RootObj {TNimTypeV2* m_type;};
struct tySequence__2ALwPJKv8Nz8mMm4Hy9crdw {
  NI len; tySequence__2ALwPJKv8Nz8mMm4Hy9crdw_Content* p;
};
struct Exception {  RootObj Sup;	Exception* parent;
	NCSTRING name;
	NimStringV2 message;
	tySequence__2ALwPJKv8Nz8mMm4Hy9crdw trace;
	Exception* up;
};
struct tyObject_CatchableError__plmui9cLQDf1IsFzhQAAHyg {  Exception Sup;};
struct tyObject_MyError__fVAoPZxkmyx7potpEdBUTw {  tyObject_CatchableError__plmui9cLQDf1IsFzhQAAHyg Sup;};
struct tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag {	NI rc;
	NI refId;
};
struct tyObject_StackTraceEntry__nOjYJiLBbFH64nNmW1UArA {	NCSTRING procname;
	NI line;
	NCSTRING filename;
};
struct tySequence__2ALwPJKv8Nz8mMm4Hy9crdw_Content { NI cap; tyObject_StackTraceEntry__nOjYJiLBbFH64nNmW1UArA data[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(NimStringV2, dollar___temp_u92)(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw x_p0);
N_LIB_PRIVATE N_NIMCALL(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw, initMyObj__temp_u10)(NimStringV2 x_p0);
static N_INLINE(void, copyMem__system_u1745)(void* dest_p0, void* source_p1, NI size_p2);
static N_INLINE(void, nimCopyMem)(void* dest_p0, void* source_p1, NI size_p2);
N_LIB_PRIVATE N_NOINLINE(void, raiseIndexError2)(NI i_p0, NI n_p1);
N_LIB_PRIVATE N_NOINLINE(void, raiseRangeErrorI)(NI64 i_p0, NI64 a_p1, NI64 b_p2);
N_LIB_PRIVATE N_NIMCALL(void*, nimNewObj)(NI size_p0, NI alignment_p1);
N_LIB_PRIVATE N_NIMCALL(void, rttiDestroy__temp_u127)(void* dest_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u27)(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* dest_p0);
static N_INLINE(NIM_BOOL, nimDecRefIsLast)(void* p_p0);
static N_INLINE(NI, minuspercent___system_u810)(NI x_p0, NI y_p1);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4156)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, writeStackTrace__system_u2550)(void);
N_LIB_PRIVATE N_NOINLINE(void, raiseOverflow)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimDestroyAndDispose)(void* p_p0);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___stdZassertions_u82)(tySequence__2ALwPJKv8Nz8mMm4Hy9crdw dest_p0);
N_LIB_PRIVATE N_NIMCALL(void, raiseExceptionEx)(Exception* e_p0, NCSTRING ename_p1, NCSTRING procname_p2, NCSTRING filename_p3, NI line_p4);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringV2* args_p0, NI args_p0Len_0);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, nsuRepeatStr)(NimStringV2 s_p0, NI n_p1);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u5)(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw x_p0);
static N_INLINE(NIM_BOOL, isObjDisplayCheck)(TNimTypeV2* source_p0, NI16 targetDepth_p1, NU32 token_p2);
static N_INLINE(Exception*, nimBorrowCurrentException)(void);
static N_INLINE(Exception*, getCurrentException)(void);
N_LIB_PRIVATE N_NIMCALL(void, eqcopy___stdZtypedthreads_u195)(Exception** dest_p0, Exception* src_p1);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u55)(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* dest_p0);
static N_INLINE(void, popCurrentException)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
N_LIB_PRIVATE TNimTypeV2 NTIv2__fVAoPZxkmyx7potpEdBUTw_;
static const struct {
  NI cap; NIM_CHAR data[16+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_4 = { 16 | NIM_STRLIT_FLAG, "This is an error" };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_5 = {16, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_4};
static const struct {
  NI cap; NIM_CHAR data[11+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_6 = { 11 | NIM_STRLIT_FLAG, "Hello world" };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_7 = {11, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_6};
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_8 = {11, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_6};
static const struct {
  NI cap; NIM_CHAR data[13+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_10 = { 13 | NIM_STRLIT_FLAG, "Got an error!" };
static NIM_CONST tyArray__nHXaesL0DJZHyVS07ARPRA TM__SRd76hP9cMfCzdUO857UhQQ_9 = {{13, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_10}}
;
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u3964;
extern NIM_THREADVAR TFrame* framePtr__system_u3602;
static NIM_CONST NU32 TM__SRd76hP9cMfCzdUO857UhQQ_3[4] = {3701606400, 1285336064, 1504611072, 1344814336};
N_LIB_PRIVATE TNimTypeV2 NTIv2__fVAoPZxkmyx7potpEdBUTw_ = {.destructor = (void*)rttiDestroy__temp_u127, .size = sizeof(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw), .align = (NI16) NIM_ALIGNOF(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw), .depth = 3, .display = TM__SRd76hP9cMfCzdUO857UhQQ_3, .traceImpl = (void*)NIM_NIL, .flags = 0};
extern NIM_THREADVAR Exception* currException__system_u3604;
#line 19 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/memory.nim"
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2) {	void* T1_;
#line 21
	T1_ = (void*)0;	T1_ = memset(a_p0, v_p1, ((size_t) (size_p2)));}
#line 423 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/excpt.nim"
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {	NIM_BOOL* result;	result = (NIM_BOOL*)0;
#line 424
	result = (&nimInErrorMode__system_u3964);	return result;}
#line 30 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/memory.nim"
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1) {NIM_BOOL* nimErr_;{nimErr_ = nimErrorFlag();
#line 31
	nimSetMem__systemZmemory_u7(p_p0, ((int)0), size_p1);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;	}BeforeRet_: ;
}
#line 8 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/memory.nim"
static N_INLINE(void, nimCopyMem)(void* dest_p0, void* source_p1, NI size_p2) {	void* T1_;
#line 10
	T1_ = (void*)0;	T1_ = memcpy(dest_p0, source_p1, ((size_t) (size_p2)));}
#line 2016 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim"
static N_INLINE(void, copyMem__system_u1745)(void* dest_p0, void* source_p1, NI size_p2) {
#line 2017
	nimCopyMem(dest_p0, source_p1, size_p2);
}
#line 549 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/excpt.nim"
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
#line 550
	{		if (!(framePtr__system_u3602 == ((TFrame*) NIM_NIL))) goto LA3_;
#line 551
		(*s_p0).calldepth = ((NI16)0);	}
	goto LA1_;
LA3_: ;
	{
#line 554
		(*s_p0).calldepth = (NI16)((*framePtr__system_u3602).calldepth + ((NI16)1));	}
LA1_: ;
#line 556
	(*s_p0).prev = framePtr__system_u3602;
#line 557
	framePtr__system_u3602 = s_p0;
#line 558
	{		if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
		callDepthLimitReached__system_u4156();
	}
LA8_: ;
}
#line 99 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/excpt.nim"
static N_INLINE(void, popFrame)(void) {
#line 100
	framePtr__system_u3602 = (*framePtr__system_u3602).prev;}
#line 363 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arithmetics.nim"
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;
#line 364
#line 368
	result = ((NI) ((NU)((NU64)(((NU) (x_p0))) - (NU64)(((NU) (y_p1))))));	popFrame();	return result;}
#line 196 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arc.nim"
static N_INLINE(NIM_BOOL, nimDecRefIsLast)(void* p_p0) {	NIM_BOOL result;	nimfr_("nimDecRefIsLast", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arc.nim");{	result = (NIM_BOOL)0;
#line 197
	{		
#line 202
int colontmpD_;		
#line 198
tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag* cell;		NI T5_;		if (!!((p_p0 == NIM_NIL))) goto LA3_;
		colontmpD_ = (int)0;
#line 43
		T5_ = (NI)0;		T5_ = minuspercent___system_u810(((NI) (ptrdiff_t) (p_p0)), ((NI)16));		cell = ((tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag*) (T5_));
#line 201
		{			if (!((*cell).refId == ((NI)20))) goto LA8_;
#line 202
			writeStackTrace__system_u2550();
#line 203
			colontmpD_ = fprintf(stderr, "[DecRef] %p %ld\012", p_p0, (NI)((NI64)((*cell).rc) >> (NU64)(((NI)3))));		}
LA8_: ;
#line 205
		{			if (!((NI)((NI64)((*cell).rc) >> (NU64)(((NI)3))) == ((NI)0))) goto LA12_;
#line 206
			result = NIM_TRUE;		}
		goto LA10_;
LA12_: ;
		{			NI TM__SRd76hP9cMfCzdUO857UhQQ_2;
#line 210
			if (nimSubInt((*cell).rc, ((NI)8), &TM__SRd76hP9cMfCzdUO857UhQQ_2)) { raiseOverflow(); goto BeforeRet_;			};			(*cell).rc = (NI)(TM__SRd76hP9cMfCzdUO857UhQQ_2);		}
LA10_: ;
	}
LA3_: ;
	}BeforeRet_: ;
	popFrame();	return result;}
#line 18 "/home/runner/work/Nim/Nim/temp.nim"
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u27)(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* dest_p0) {	{		NIM_BOOL T3_;		T3_ = (NIM_BOOL)0;		T3_ = nimDecRefIsLast((*dest_p0).Sup.Sup.parent);		if (!T3_) goto LA4_;
		nimDestroyAndDispose((*dest_p0).Sup.Sup.parent);
	}
LA4_: ;
	if ((*dest_p0).Sup.Sup.message.p && !((*dest_p0).Sup.Sup.message.p->cap & NIM_STRLIT_FLAG)) { deallocShared((*dest_p0).Sup.Sup.message.p);}	eqdestroy___stdZassertions_u82((*dest_p0).Sup.Sup.trace);
	{		NIM_BOOL T8_;		T8_ = (NIM_BOOL)0;		T8_ = nimDecRefIsLast((*dest_p0).Sup.Sup.up);		if (!T8_) goto LA9_;
		nimDestroyAndDispose((*dest_p0).Sup.Sup.up);
	}
LA9_: ;
}
#line 18 "/home/runner/work/Nim/Nim/temp.nim"
N_LIB_PRIVATE N_NIMCALL(void, rttiDestroy__temp_u127)(void* dest_p0) {NIM_BOOL* nimErr_;{nimErr_ = nimErrorFlag();	eqdestroy___temp_u27(((tyObject_MyError__fVAoPZxkmyx7potpEdBUTw*) (dest_p0)));
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;	}BeforeRet_: ;
}
#line 13 "/home/runner/work/Nim/Nim/temp.nim"
N_LIB_PRIVATE N_NIMCALL(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw, initMyObj__temp_u10)(NimStringV2 x_p0) {	tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw result;	nimfr_("initMyObj", "/home/runner/work/Nim/Nim/temp.nim");{	nimZeroMem((void*)(&result), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));
#line 14
	nimZeroMem((void*)(&result), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));	result.internal = malloc(((size_t)126));
#line 15
	{		if (!(x_p0.len < ((NI)128))) goto LA3_;
#line 16
		if (((NI)0) < 0 || ((NI)0) >= x_p0.len){ raiseIndexError2(((NI)0),x_p0.len-1); goto BeforeRet_;		}		if ((x_p0.len) < ((NI)0) || (x_p0.len) > ((NI)IL64(9223372036854775807))){ raiseRangeErrorI(x_p0.len, ((NI)0), ((NI)IL64(9223372036854775807))); goto BeforeRet_;		}		copyMem__system_u1745(result.internal, ((void*) ((&x_p0.p->data[((NI)0)]))), ((NI) (x_p0.len)));
	}
	goto LA1_;
LA3_: ;
	{		tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* T6_;		T6_ = NIM_NIL;		T6_ = (tyObject_MyError__fVAoPZxkmyx7potpEdBUTw*) nimNewObj(sizeof(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw), NIM_ALIGNOF(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw));		(*T6_).Sup.Sup.Sup.m_type = (&NTIv2__fVAoPZxkmyx7potpEdBUTw_);		(*T6_).Sup.Sup.name = "MyError";		(*T6_).Sup.Sup.message = TM__SRd76hP9cMfCzdUO857UhQQ_5;		(*T6_).Sup.Sup.parent = ((Exception*) NIM_NIL);
#line 18
		raiseExceptionEx((Exception*)T6_, "MyError", "initMyObj", "/home/runner/work/Nim/Nim/temp.nim", 18);goto BeforeRet_;	}
LA1_: ;
	}BeforeRet_: ;
	popFrame();	return result;}
#line 6 "/home/runner/work/Nim/Nim/temp.nim"
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u5)(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw x_p0) {	nimfr_("=destroy", "/home/runner/work/Nim/Nim/temp.nim");{
#line 7
	{		if (!(x_p0.internal == 0)) goto LA3_;
		goto BeforeRet_;
	}
LA3_: ;
#line 8
	free(x_p0.internal);
	}BeforeRet_: ;
	popFrame();}
#line 237 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arc.nim"
static N_INLINE(NIM_BOOL, isObjDisplayCheck)(TNimTypeV2* source_p0, NI16 targetDepth_p1, NU32 token_p2) {	NIM_BOOL result;	NIM_BOOL T1_;	nimfr_("isObjDisplayCheck", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arc.nim");	result = (NIM_BOOL)0;
#line 238
	T1_ = (NIM_BOOL)0;	T1_ = (targetDepth_p1 <= (*source_p0).depth);	if (!(T1_)) goto LA2_;
	T1_ = ((*source_p0).display[targetDepth_p1] == token_p2);LA2_: ;
	result = T1_;	popFrame();	return result;}
#line 2209 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim"
static N_INLINE(Exception*, nimBorrowCurrentException)(void) {	Exception* result;	nimfr_("nimBorrowCurrentException", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim");	result = NIM_NIL;
#line 2212
	result = currException__system_u3604;	popFrame();	return result;}
#line 2205 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim"
static N_INLINE(Exception*, getCurrentException)(void) {	Exception* result;	nimfr_("getCurrentException", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim");	result = NIM_NIL;
#line 247 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/std/typedthreads.nim"
	eqcopy___stdZtypedthreads_u195(&result, currException__system_u3604);
	popFrame();	return result;}
#line 18 "/home/runner/work/Nim/Nim/temp.nim"
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u55)(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* dest_p0) {	{		NIM_BOOL T3_;		T3_ = (NIM_BOOL)0;		T3_ = nimDecRefIsLast(dest_p0);		if (!T3_) goto LA4_;
		nimDestroyAndDispose(dest_p0);
	}
LA4_: ;
}
#line 137 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/excpt.nim"
static N_INLINE(void, popCurrentException)(void) {
#line 247 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/std/typedthreads.nim"
	eqcopy___stdZtypedthreads_u195(&currException__system_u3604, (*currException__system_u3604).up);
}
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) {
#line 999999 "generated_not_to_break_here"
{
#line 21 "/home/runner/work/Nim/Nim/temp.nim"
tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw colontmpD_;	NimStringV2 colontmpD__2;	
#line 22
NimStringV2 colontmpD__3;	tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw colontmpD__4;	NimStringV2 colontmpD__5;	tyArray__nHXaesL0DJZHyVS07ARPRA T3_;	tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw T4_;	NimStringV2 T5_;	tyArray__nHXaesL0DJZHyVS07ARPRA T6_;	NimStringV2 T7_;	tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw T8_;	NimStringV2 T9_;NIM_BOOL oldNimErrFin2_;NIM_BOOL oldNimErrFin15_;NIM_BOOL* nimErr_;	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");nimErr_ = nimErrorFlag();	nimZeroMem((void*)(&colontmpD_), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));	colontmpD__2.len = 0; colontmpD__2.p = NIM_NIL;	colontmpD__3.len = 0; colontmpD__3.p = NIM_NIL;	nimZeroMem((void*)(&colontmpD__4), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));	colontmpD__5.len = 0; colontmpD__5.p = NIM_NIL;
#line 21
	nimZeroMem((void*)(&T4_), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));	T4_ = initMyObj__temp_u10(TM__SRd76hP9cMfCzdUO857UhQQ_7);	if (NIM_UNLIKELY(*nimErr_)) goto LA2_;	colontmpD_ = T4_;	T5_.len = 0; T5_.p = NIM_NIL;	T5_ = dollar___temp_u92(colontmpD_);	if (NIM_UNLIKELY(*nimErr_)) goto LA2_;	colontmpD__2 = T5_;	T3_[0] = colontmpD__2;	echoBinSafe(T3_, 1);
#line 22
	T7_.len = 0; T7_.p = NIM_NIL;	T7_ = nsuRepeatStr(TM__SRd76hP9cMfCzdUO857UhQQ_8, ((NI)128));	if (NIM_UNLIKELY(*nimErr_)) goto LA2_;	colontmpD__3 = T7_;	nimZeroMem((void*)(&T8_), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));	T8_ = initMyObj__temp_u10(colontmpD__3);	if (NIM_UNLIKELY(*nimErr_)) goto LA2_;	colontmpD__4 = T8_;	T9_.len = 0; T9_.p = NIM_NIL;	T9_ = dollar___temp_u92(colontmpD__4);	if (NIM_UNLIKELY(*nimErr_)) goto LA2_;	colontmpD__5 = T9_;	T6_[0] = colontmpD__5;	echoBinSafe(T6_, 1);	{		LA2_:;	}
	{		oldNimErrFin2_ = *nimErr_; *nimErr_ = NIM_FALSE;
#line 370 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim"
		if (colontmpD__5.p && !(colontmpD__5.p->cap & NIM_STRLIT_FLAG)) { deallocShared(colontmpD__5.p);}
#line 6 "/home/runner/work/Nim/Nim/temp.nim"
		eqdestroy___temp_u5(colontmpD__4);
		if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
#line 370 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim"
		if (colontmpD__3.p && !(colontmpD__3.p->cap & NIM_STRLIT_FLAG)) { deallocShared(colontmpD__3.p);}		if (colontmpD__2.p && !(colontmpD__2.p->cap & NIM_STRLIT_FLAG)) { deallocShared(colontmpD__2.p);}
#line 6 "/home/runner/work/Nim/Nim/temp.nim"
		eqdestroy___temp_u5(colontmpD_);
		if (NIM_UNLIKELY(*nimErr_)) goto LA1_;		*nimErr_ = oldNimErrFin2_;	}
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;	if (NIM_UNLIKELY(*nimErr_)) {		LA1_:;		if (isObjDisplayCheck(nimBorrowCurrentException()->Sup.m_type, 3, 1344814336)) {			
#line 23
tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* e;			Exception* T16_;			tyArray__nHXaesL0DJZHyVS07ARPRA T17_;			*nimErr_ = NIM_FALSE;			e = NIM_NIL;
#line 24
			T16_ = NIM_NIL;			T16_ = getCurrentException();			e = ((tyObject_MyError__fVAoPZxkmyx7potpEdBUTw*) (T16_));
#line 24 "/home/runner/work/Nim/Nim/temp.nim"
			echoBinSafe(TM__SRd76hP9cMfCzdUO857UhQQ_9, 1);
#line 25
			T17_[0] = (*e).Sup.Sup.message;			echoBinSafe(T17_, 1);			{				LA15_:;			}
			{				oldNimErrFin15_ = *nimErr_; *nimErr_ = NIM_FALSE;
#line 18
				eqdestroy___temp_u55(e);
				if (NIM_UNLIKELY(*nimErr_)) goto LA13_;				*nimErr_ = oldNimErrFin15_;			}
			if (NIM_UNLIKELY(*nimErr_)) goto LA13_;			popCurrentException();			LA13_:;		}
	}
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;	BeforeRet_: ;
	nimTestErrorFlag();	popFrame();}
}

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("system"),
      newIdentNode("ansi_c")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("MyError"),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        nnkOfInherit.newTree(
          newIdentNode("CatchableError")
        ),
        newEmptyNode()
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("MyObj"),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("internal"),
            newIdentNode("pointer"),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    nnkAccQuoted.newTree(
      newIdentNode("="),
      newIdentNode("destroy")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("MyObj"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkIfStmt.newTree(
        nnkElifBranch.newTree(
          nnkDotExpr.newTree(
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("internal")
            ),
            newIdentNode("isNil")
          ),
          nnkStmtList.newTree(
            nnkReturnStmt.newTree(
              newEmptyNode()
            )
          )
        )
      ),
      nnkDotExpr.newTree(
        nnkDotExpr.newTree(
          newIdentNode("x"),
          newIdentNode("internal")
        ),
        newIdentNode("c_free")
      )
    )
  ),
  nnkProcDef.newTree(
    nnkAccQuoted.newTree(
      newIdentNode("="),
      newIdentNode("copy")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkVarTy.newTree(
          newIdentNode("MyObj")
        ),
        newEmptyNode()
      ),
      nnkIdentDefs.newTree(
        newIdentNode("y"),
        newIdentNode("MyObj"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkIfStmt.newTree(
        nnkElifBranch.newTree(
          nnkInfix.newTree(
            newIdentNode("!="),
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("internal")
            ),
            nnkDotExpr.newTree(
              newIdentNode("y"),
              newIdentNode("internal")
            )
          ),
          nnkStmtList.newTree(
            nnkDotExpr.newTree(
              nnkDotExpr.newTree(
                newIdentNode("x"),
                newIdentNode("internal")
              ),
              newIdentNode("c_free")
            ),
            nnkAsgn.newTree(
              nnkDotExpr.newTree(
                newIdentNode("x"),
                newIdentNode("internal")
              ),
              nnkDotExpr.newTree(
                newIdentNode("y"),
                newIdentNode("internal")
              )
            )
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("initMyObj"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("MyObj"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("string"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkAsgn.newTree(
        newIdentNode("result"),
        nnkObjConstr.newTree(
          newIdentNode("MyObj"),
          nnkExprColonExpr.newTree(
            newIdentNode("internal"),
            nnkCall.newTree(
              newIdentNode("c_malloc"),
              newLit(126)
            )
          )
        )
      ),
      nnkIfStmt.newTree(
        nnkElifBranch.newTree(
          nnkInfix.newTree(
            newIdentNode("<"),
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("len")
            ),
            newLit(128)
          ),
          nnkStmtList.newTree(
            nnkCall.newTree(
              nnkDotExpr.newTree(
                nnkDotExpr.newTree(
                  newIdentNode("result"),
                  newIdentNode("internal")
                ),
                newIdentNode("copyMem")
              ),
              nnkDotExpr.newTree(
                nnkBracketExpr.newTree(
                  newIdentNode("x"),
                  newLit(0)
                ),
                newIdentNode("addr")
              ),
              nnkDotExpr.newTree(
                newIdentNode("x"),
                newIdentNode("len")
              )
            )
          )
        ),
        nnkElse.newTree(
          nnkStmtList.newTree(
            nnkRaiseStmt.newTree(
              nnkCall.newTree(
                newIdentNode("newException"),
                newIdentNode("MyError"),
                newLit("This is an error")
              )
            )
          )
        )
      )
    )
  ),
  nnkImportStmt.newTree(
    newIdentNode("strutils")
  ),
  nnkTryStmt.newTree(
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        nnkCall.newTree(
          newIdentNode("initMyObj"),
          newLit("Hello world")
        )
      ),
      nnkCommand.newTree(
        newIdentNode("echo"),
        nnkCall.newTree(
          newIdentNode("initMyObj"),
          nnkCall.newTree(
            nnkDotExpr.newTree(
              newLit("Hello world"),
              newIdentNode("repeat")
            ),
            newLit(128)
          )
        )
      )
    ),
    nnkExceptBranch.newTree(
      nnkInfix.newTree(
        newIdentNode("as"),
        newIdentNode("MyError"),
        newIdentNode("e")
      ),
      nnkStmtList.newTree(
        nnkCommand.newTree(
          newIdentNode("echo"),
          newLit("Got an error!")
        ),
        nnkCommand.newTree(
          newIdentNode("echo"),
          nnkDotExpr.newTree(
            newIdentNode("e"),
            newIdentNode("msg")
          )
        )
      )
    )
  )
)
1.2.0 👎 FAIL

Output

Error: Command failed: nim c --gc:arc -d:useMalloc --expandArc:initMyObj -d:nimArcDebug -d:nimArcIds  -d:nimAllocPagesViaMalloc -d:useSysAssert -d:useGcAssert -d:nimLeakDetector --debugger:native --debuginfo:on  -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim && valgrind /home/runner/work/Nim/Nim/temp
command line(1, 2) Error: invalid command line option: '--expandArc'

Stats

  • Started 2023-09-08T13:30:09
  • Finished 2023-09-08T13:30:09
  • Duration

IR

Compiled filesize 353.13 Kb (361,600 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
#define nimfr_(proc, file) \
  TFrame FR_; \
  FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
  #define nimfrs_(proc, file, slots, length) \
    struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename;NI len;VarSlot s[slots];} FR_; \
    FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
  #define nimln_(n) \
    FR_.line = n;
  #define nimlf_(n, file) \
    FR_.line = n; FR_.filename = file;
typedef struct tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
typedef struct tyObject_MyError__fVAoPZxkmyx7potpEdBUTw tyObject_MyError__fVAoPZxkmyx7potpEdBUTw;
typedef struct tyObject_CatchableError__plmui9cLQDf1IsFzhQAAHyg tyObject_CatchableError__plmui9cLQDf1IsFzhQAAHyg;
typedef struct Exception Exception;
typedef struct RootObj RootObj;
typedef struct TNimTypeV2 TNimTypeV2;
typedef struct tySequence__2ALwPJKv8Nz8mMm4Hy9crdw tySequence__2ALwPJKv8Nz8mMm4Hy9crdw;
typedef struct tySequence__2ALwPJKv8Nz8mMm4Hy9crdw_Content tySequence__2ALwPJKv8Nz8mMm4Hy9crdw_Content;
typedef struct tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag;
typedef struct tyObject_StackTraceEntry__nOjYJiLBbFH64nNmW1UArA tyObject_StackTraceEntry__nOjYJiLBbFH64nNmW1UArA;
struct tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw {	void* internal;
};
struct NimStrPayload {	NI cap;
	NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {	NI len;
	NimStrPayload* p;
};
typedef NimStringV2 tyArray__nHXaesL0DJZHyVS07ARPRA[1];
struct TNimTypeV2 {	void* destructor;
	NI size;
	NI16 align;
	NI16 depth;
	NU32* display;
	NCSTRING name;
	void* traceImpl;
	void* typeInfoV1;
	NI flags;
};
struct RootObj {TNimTypeV2* m_type;};
struct tySequence__2ALwPJKv8Nz8mMm4Hy9crdw {
  NI len; tySequence__2ALwPJKv8Nz8mMm4Hy9crdw_Content* p;
};
struct Exception {  RootObj Sup;	Exception* parent;
	NCSTRING name;
	NimStringV2 message;
	tySequence__2ALwPJKv8Nz8mMm4Hy9crdw trace;
	Exception* up;
};
struct tyObject_CatchableError__plmui9cLQDf1IsFzhQAAHyg {  Exception Sup;};
struct tyObject_MyError__fVAoPZxkmyx7potpEdBUTw {  tyObject_CatchableError__plmui9cLQDf1IsFzhQAAHyg Sup;};
struct tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag {	NI rc;
	NI refId;
};
struct tyObject_StackTraceEntry__nOjYJiLBbFH64nNmW1UArA {	NCSTRING procname;
	NI line;
	NCSTRING filename;
};
struct tySequence__2ALwPJKv8Nz8mMm4Hy9crdw_Content { NI cap; tyObject_StackTraceEntry__nOjYJiLBbFH64nNmW1UArA data[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(NimStringV2, dollar___temp_u92)(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw x_p0);
N_LIB_PRIVATE N_NIMCALL(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw, initMyObj__temp_u10)(NimStringV2 x_p0);
static N_INLINE(void, copyMem__system_u1745)(void* dest_p0, void* source_p1, NI size_p2);
static N_INLINE(void, nimCopyMem)(void* dest_p0, void* source_p1, NI size_p2);
N_LIB_PRIVATE N_NOINLINE(void, raiseIndexError2)(NI i_p0, NI n_p1);
N_LIB_PRIVATE N_NOINLINE(void, raiseRangeErrorI)(NI64 i_p0, NI64 a_p1, NI64 b_p2);
N_LIB_PRIVATE N_NIMCALL(void*, nimNewObj)(NI size_p0, NI alignment_p1);
N_LIB_PRIVATE N_NIMCALL(void, rttiDestroy__temp_u127)(void* dest_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u27)(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* dest_p0);
static N_INLINE(NIM_BOOL, nimDecRefIsLast)(void* p_p0);
static N_INLINE(NI, minuspercent___system_u810)(NI x_p0, NI y_p1);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4156)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, writeStackTrace__system_u2550)(void);
N_LIB_PRIVATE N_NOINLINE(void, raiseOverflow)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimDestroyAndDispose)(void* p_p0);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___stdZassertions_u82)(tySequence__2ALwPJKv8Nz8mMm4Hy9crdw dest_p0);
N_LIB_PRIVATE N_NIMCALL(void, raiseExceptionEx)(Exception* e_p0, NCSTRING ename_p1, NCSTRING procname_p2, NCSTRING filename_p3, NI line_p4);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringV2* args_p0, NI args_p0Len_0);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, nsuRepeatStr)(NimStringV2 s_p0, NI n_p1);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u5)(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw x_p0);
static N_INLINE(NIM_BOOL, isObjDisplayCheck)(TNimTypeV2* source_p0, NI16 targetDepth_p1, NU32 token_p2);
static N_INLINE(Exception*, nimBorrowCurrentException)(void);
static N_INLINE(Exception*, getCurrentException)(void);
N_LIB_PRIVATE N_NIMCALL(void, eqcopy___stdZtypedthreads_u195)(Exception** dest_p0, Exception* src_p1);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u55)(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* dest_p0);
static N_INLINE(void, popCurrentException)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
N_LIB_PRIVATE TNimTypeV2 NTIv2__fVAoPZxkmyx7potpEdBUTw_;
static const struct {
  NI cap; NIM_CHAR data[16+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_4 = { 16 | NIM_STRLIT_FLAG, "This is an error" };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_5 = {16, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_4};
static const struct {
  NI cap; NIM_CHAR data[11+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_6 = { 11 | NIM_STRLIT_FLAG, "Hello world" };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_7 = {11, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_6};
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_8 = {11, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_6};
static const struct {
  NI cap; NIM_CHAR data[13+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_10 = { 13 | NIM_STRLIT_FLAG, "Got an error!" };
static NIM_CONST tyArray__nHXaesL0DJZHyVS07ARPRA TM__SRd76hP9cMfCzdUO857UhQQ_9 = {{13, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_10}}
;
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u3964;
extern NIM_THREADVAR TFrame* framePtr__system_u3602;
static NIM_CONST NU32 TM__SRd76hP9cMfCzdUO857UhQQ_3[4] = {3701606400, 1285336064, 1504611072, 1344814336};
N_LIB_PRIVATE TNimTypeV2 NTIv2__fVAoPZxkmyx7potpEdBUTw_ = {.destructor = (void*)rttiDestroy__temp_u127, .size = sizeof(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw), .align = (NI16) NIM_ALIGNOF(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw), .depth = 3, .display = TM__SRd76hP9cMfCzdUO857UhQQ_3, .traceImpl = (void*)NIM_NIL, .flags = 0};
extern NIM_THREADVAR Exception* currException__system_u3604;
#line 19 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/memory.nim"
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2) {	void* T1_;
#line 21
	T1_ = (void*)0;	T1_ = memset(a_p0, v_p1, ((size_t) (size_p2)));}
#line 423 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/excpt.nim"
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {	NIM_BOOL* result;	result = (NIM_BOOL*)0;
#line 424
	result = (&nimInErrorMode__system_u3964);	return result;}
#line 30 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/memory.nim"
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1) {NIM_BOOL* nimErr_;{nimErr_ = nimErrorFlag();
#line 31
	nimSetMem__systemZmemory_u7(p_p0, ((int)0), size_p1);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;	}BeforeRet_: ;
}
#line 8 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/memory.nim"
static N_INLINE(void, nimCopyMem)(void* dest_p0, void* source_p1, NI size_p2) {	void* T1_;
#line 10
	T1_ = (void*)0;	T1_ = memcpy(dest_p0, source_p1, ((size_t) (size_p2)));}
#line 2016 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim"
static N_INLINE(void, copyMem__system_u1745)(void* dest_p0, void* source_p1, NI size_p2) {
#line 2017
	nimCopyMem(dest_p0, source_p1, size_p2);
}
#line 549 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/excpt.nim"
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
#line 550
	{		if (!(framePtr__system_u3602 == ((TFrame*) NIM_NIL))) goto LA3_;
#line 551
		(*s_p0).calldepth = ((NI16)0);	}
	goto LA1_;
LA3_: ;
	{
#line 554
		(*s_p0).calldepth = (NI16)((*framePtr__system_u3602).calldepth + ((NI16)1));	}
LA1_: ;
#line 556
	(*s_p0).prev = framePtr__system_u3602;
#line 557
	framePtr__system_u3602 = s_p0;
#line 558
	{		if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
		callDepthLimitReached__system_u4156();
	}
LA8_: ;
}
#line 99 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/excpt.nim"
static N_INLINE(void, popFrame)(void) {
#line 100
	framePtr__system_u3602 = (*framePtr__system_u3602).prev;}
#line 363 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arithmetics.nim"
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;
#line 364
#line 368
	result = ((NI) ((NU)((NU64)(((NU) (x_p0))) - (NU64)(((NU) (y_p1))))));	popFrame();	return result;}
#line 196 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arc.nim"
static N_INLINE(NIM_BOOL, nimDecRefIsLast)(void* p_p0) {	NIM_BOOL result;	nimfr_("nimDecRefIsLast", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arc.nim");{	result = (NIM_BOOL)0;
#line 197
	{		
#line 202
int colontmpD_;		
#line 198
tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag* cell;		NI T5_;		if (!!((p_p0 == NIM_NIL))) goto LA3_;
		colontmpD_ = (int)0;
#line 43
		T5_ = (NI)0;		T5_ = minuspercent___system_u810(((NI) (ptrdiff_t) (p_p0)), ((NI)16));		cell = ((tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag*) (T5_));
#line 201
		{			if (!((*cell).refId == ((NI)20))) goto LA8_;
#line 202
			writeStackTrace__system_u2550();
#line 203
			colontmpD_ = fprintf(stderr, "[DecRef] %p %ld\012", p_p0, (NI)((NI64)((*cell).rc) >> (NU64)(((NI)3))));		}
LA8_: ;
#line 205
		{			if (!((NI)((NI64)((*cell).rc) >> (NU64)(((NI)3))) == ((NI)0))) goto LA12_;
#line 206
			result = NIM_TRUE;		}
		goto LA10_;
LA12_: ;
		{			NI TM__SRd76hP9cMfCzdUO857UhQQ_2;
#line 210
			if (nimSubInt((*cell).rc, ((NI)8), &TM__SRd76hP9cMfCzdUO857UhQQ_2)) { raiseOverflow(); goto BeforeRet_;			};			(*cell).rc = (NI)(TM__SRd76hP9cMfCzdUO857UhQQ_2);		}
LA10_: ;
	}
LA3_: ;
	}BeforeRet_: ;
	popFrame();	return result;}
#line 18 "/home/runner/work/Nim/Nim/temp.nim"
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u27)(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* dest_p0) {	{		NIM_BOOL T3_;		T3_ = (NIM_BOOL)0;		T3_ = nimDecRefIsLast((*dest_p0).Sup.Sup.parent);		if (!T3_) goto LA4_;
		nimDestroyAndDispose((*dest_p0).Sup.Sup.parent);
	}
LA4_: ;
	if ((*dest_p0).Sup.Sup.message.p && !((*dest_p0).Sup.Sup.message.p->cap & NIM_STRLIT_FLAG)) { deallocShared((*dest_p0).Sup.Sup.message.p);}	eqdestroy___stdZassertions_u82((*dest_p0).Sup.Sup.trace);
	{		NIM_BOOL T8_;		T8_ = (NIM_BOOL)0;		T8_ = nimDecRefIsLast((*dest_p0).Sup.Sup.up);		if (!T8_) goto LA9_;
		nimDestroyAndDispose((*dest_p0).Sup.Sup.up);
	}
LA9_: ;
}
#line 18 "/home/runner/work/Nim/Nim/temp.nim"
N_LIB_PRIVATE N_NIMCALL(void, rttiDestroy__temp_u127)(void* dest_p0) {NIM_BOOL* nimErr_;{nimErr_ = nimErrorFlag();	eqdestroy___temp_u27(((tyObject_MyError__fVAoPZxkmyx7potpEdBUTw*) (dest_p0)));
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;	}BeforeRet_: ;
}
#line 13 "/home/runner/work/Nim/Nim/temp.nim"
N_LIB_PRIVATE N_NIMCALL(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw, initMyObj__temp_u10)(NimStringV2 x_p0) {	tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw result;	nimfr_("initMyObj", "/home/runner/work/Nim/Nim/temp.nim");{	nimZeroMem((void*)(&result), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));
#line 14
	nimZeroMem((void*)(&result), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));	result.internal = malloc(((size_t)126));
#line 15
	{		if (!(x_p0.len < ((NI)128))) goto LA3_;
#line 16
		if (((NI)0) < 0 || ((NI)0) >= x_p0.len){ raiseIndexError2(((NI)0),x_p0.len-1); goto BeforeRet_;		}		if ((x_p0.len) < ((NI)0) || (x_p0.len) > ((NI)IL64(9223372036854775807))){ raiseRangeErrorI(x_p0.len, ((NI)0), ((NI)IL64(9223372036854775807))); goto BeforeRet_;		}		copyMem__system_u1745(result.internal, ((void*) ((&x_p0.p->data[((NI)0)]))), ((NI) (x_p0.len)));
	}
	goto LA1_;
LA3_: ;
	{		tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* T6_;		T6_ = NIM_NIL;		T6_ = (tyObject_MyError__fVAoPZxkmyx7potpEdBUTw*) nimNewObj(sizeof(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw), NIM_ALIGNOF(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw));		(*T6_).Sup.Sup.Sup.m_type = (&NTIv2__fVAoPZxkmyx7potpEdBUTw_);		(*T6_).Sup.Sup.name = "MyError";		(*T6_).Sup.Sup.message = TM__SRd76hP9cMfCzdUO857UhQQ_5;		(*T6_).Sup.Sup.parent = ((Exception*) NIM_NIL);
#line 18
		raiseExceptionEx((Exception*)T6_, "MyError", "initMyObj", "/home/runner/work/Nim/Nim/temp.nim", 18);goto BeforeRet_;	}
LA1_: ;
	}BeforeRet_: ;
	popFrame();	return result;}
#line 6 "/home/runner/work/Nim/Nim/temp.nim"
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u5)(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw x_p0) {	nimfr_("=destroy", "/home/runner/work/Nim/Nim/temp.nim");{
#line 7
	{		if (!(x_p0.internal == 0)) goto LA3_;
		goto BeforeRet_;
	}
LA3_: ;
#line 8
	free(x_p0.internal);
	}BeforeRet_: ;
	popFrame();}
#line 237 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arc.nim"
static N_INLINE(NIM_BOOL, isObjDisplayCheck)(TNimTypeV2* source_p0, NI16 targetDepth_p1, NU32 token_p2) {	NIM_BOOL result;	NIM_BOOL T1_;	nimfr_("isObjDisplayCheck", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arc.nim");	result = (NIM_BOOL)0;
#line 238
	T1_ = (NIM_BOOL)0;	T1_ = (targetDepth_p1 <= (*source_p0).depth);	if (!(T1_)) goto LA2_;
	T1_ = ((*source_p0).display[targetDepth_p1] == token_p2);LA2_: ;
	result = T1_;	popFrame();	return result;}
#line 2209 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim"
static N_INLINE(Exception*, nimBorrowCurrentException)(void) {	Exception* result;	nimfr_("nimBorrowCurrentException", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim");	result = NIM_NIL;
#line 2212
	result = currException__system_u3604;	popFrame();	return result;}
#line 2205 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim"
static N_INLINE(Exception*, getCurrentException)(void) {	Exception* result;	nimfr_("getCurrentException", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim");	result = NIM_NIL;
#line 247 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/std/typedthreads.nim"
	eqcopy___stdZtypedthreads_u195(&result, currException__system_u3604);
	popFrame();	return result;}
#line 18 "/home/runner/work/Nim/Nim/temp.nim"
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u55)(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* dest_p0) {	{		NIM_BOOL T3_;		T3_ = (NIM_BOOL)0;		T3_ = nimDecRefIsLast(dest_p0);		if (!T3_) goto LA4_;
		nimDestroyAndDispose(dest_p0);
	}
LA4_: ;
}
#line 137 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/excpt.nim"
static N_INLINE(void, popCurrentException)(void) {
#line 247 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/std/typedthreads.nim"
	eqcopy___stdZtypedthreads_u195(&currException__system_u3604, (*currException__system_u3604).up);
}
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) {
#line 999999 "generated_not_to_break_here"
{
#line 21 "/home/runner/work/Nim/Nim/temp.nim"
tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw colontmpD_;	NimStringV2 colontmpD__2;	
#line 22
NimStringV2 colontmpD__3;	tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw colontmpD__4;	NimStringV2 colontmpD__5;	tyArray__nHXaesL0DJZHyVS07ARPRA T3_;	tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw T4_;	NimStringV2 T5_;	tyArray__nHXaesL0DJZHyVS07ARPRA T6_;	NimStringV2 T7_;	tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw T8_;	NimStringV2 T9_;NIM_BOOL oldNimErrFin2_;NIM_BOOL oldNimErrFin15_;NIM_BOOL* nimErr_;	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");nimErr_ = nimErrorFlag();	nimZeroMem((void*)(&colontmpD_), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));	colontmpD__2.len = 0; colontmpD__2.p = NIM_NIL;	colontmpD__3.len = 0; colontmpD__3.p = NIM_NIL;	nimZeroMem((void*)(&colontmpD__4), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));	colontmpD__5.len = 0; colontmpD__5.p = NIM_NIL;
#line 21
	nimZeroMem((void*)(&T4_), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));	T4_ = initMyObj__temp_u10(TM__SRd76hP9cMfCzdUO857UhQQ_7);	if (NIM_UNLIKELY(*nimErr_)) goto LA2_;	colontmpD_ = T4_;	T5_.len = 0; T5_.p = NIM_NIL;	T5_ = dollar___temp_u92(colontmpD_);	if (NIM_UNLIKELY(*nimErr_)) goto LA2_;	colontmpD__2 = T5_;	T3_[0] = colontmpD__2;	echoBinSafe(T3_, 1);
#line 22
	T7_.len = 0; T7_.p = NIM_NIL;	T7_ = nsuRepeatStr(TM__SRd76hP9cMfCzdUO857UhQQ_8, ((NI)128));	if (NIM_UNLIKELY(*nimErr_)) goto LA2_;	colontmpD__3 = T7_;	nimZeroMem((void*)(&T8_), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));	T8_ = initMyObj__temp_u10(colontmpD__3);	if (NIM_UNLIKELY(*nimErr_)) goto LA2_;	colontmpD__4 = T8_;	T9_.len = 0; T9_.p = NIM_NIL;	T9_ = dollar___temp_u92(colontmpD__4);	if (NIM_UNLIKELY(*nimErr_)) goto LA2_;	colontmpD__5 = T9_;	T6_[0] = colontmpD__5;	echoBinSafe(T6_, 1);	{		LA2_:;	}
	{		oldNimErrFin2_ = *nimErr_; *nimErr_ = NIM_FALSE;
#line 370 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim"
		if (colontmpD__5.p && !(colontmpD__5.p->cap & NIM_STRLIT_FLAG)) { deallocShared(colontmpD__5.p);}
#line 6 "/home/runner/work/Nim/Nim/temp.nim"
		eqdestroy___temp_u5(colontmpD__4);
		if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
#line 370 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim"
		if (colontmpD__3.p && !(colontmpD__3.p->cap & NIM_STRLIT_FLAG)) { deallocShared(colontmpD__3.p);}		if (colontmpD__2.p && !(colontmpD__2.p->cap & NIM_STRLIT_FLAG)) { deallocShared(colontmpD__2.p);}
#line 6 "/home/runner/work/Nim/Nim/temp.nim"
		eqdestroy___temp_u5(colontmpD_);
		if (NIM_UNLIKELY(*nimErr_)) goto LA1_;		*nimErr_ = oldNimErrFin2_;	}
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;	if (NIM_UNLIKELY(*nimErr_)) {		LA1_:;		if (isObjDisplayCheck(nimBorrowCurrentException()->Sup.m_type, 3, 1344814336)) {			
#line 23
tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* e;			Exception* T16_;			tyArray__nHXaesL0DJZHyVS07ARPRA T17_;			*nimErr_ = NIM_FALSE;			e = NIM_NIL;
#line 24
			T16_ = NIM_NIL;			T16_ = getCurrentException();			e = ((tyObject_MyError__fVAoPZxkmyx7potpEdBUTw*) (T16_));
#line 24 "/home/runner/work/Nim/Nim/temp.nim"
			echoBinSafe(TM__SRd76hP9cMfCzdUO857UhQQ_9, 1);
#line 25
			T17_[0] = (*e).Sup.Sup.message;			echoBinSafe(T17_, 1);			{				LA15_:;			}
			{				oldNimErrFin15_ = *nimErr_; *nimErr_ = NIM_FALSE;
#line 18
				eqdestroy___temp_u55(e);
				if (NIM_UNLIKELY(*nimErr_)) goto LA13_;				*nimErr_ = oldNimErrFin15_;			}
			if (NIM_UNLIKELY(*nimErr_)) goto LA13_;			popCurrentException();			LA13_:;		}
	}
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;	BeforeRet_: ;
	nimTestErrorFlag();	popFrame();}
}

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("system"),
      newIdentNode("ansi_c")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("MyError"),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        nnkOfInherit.newTree(
          newIdentNode("CatchableError")
        ),
        newEmptyNode()
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("MyObj"),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("internal"),
            newIdentNode("pointer"),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    nnkAccQuoted.newTree(
      newIdentNode("="),
      newIdentNode("destroy")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("MyObj"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkIfStmt.newTree(
        nnkElifBranch.newTree(
          nnkDotExpr.newTree(
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("internal")
            ),
            newIdentNode("isNil")
          ),
          nnkStmtList.newTree(
            nnkReturnStmt.newTree(
              newEmptyNode()
            )
          )
        )
      ),
      nnkDotExpr.newTree(
        nnkDotExpr.newTree(
          newIdentNode("x"),
          newIdentNode("internal")
        ),
        newIdentNode("c_free")
      )
    )
  ),
  nnkProcDef.newTree(
    nnkAccQuoted.newTree(
      newIdentNode("="),
      newIdentNode("copy")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkVarTy.newTree(
          newIdentNode("MyObj")
        ),
        newEmptyNode()
      ),
      nnkIdentDefs.newTree(
        newIdentNode("y"),
        newIdentNode("MyObj"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkIfStmt.newTree(
        nnkElifBranch.newTree(
          nnkInfix.newTree(
            newIdentNode("!="),
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("internal")
            ),
            nnkDotExpr.newTree(
              newIdentNode("y"),
              newIdentNode("internal")
            )
          ),
          nnkStmtList.newTree(
            nnkDotExpr.newTree(
              nnkDotExpr.newTree(
                newIdentNode("x"),
                newIdentNode("internal")
              ),
              newIdentNode("c_free")
            ),
            nnkAsgn.newTree(
              nnkDotExpr.newTree(
                newIdentNode("x"),
                newIdentNode("internal")
              ),
              nnkDotExpr.newTree(
                newIdentNode("y"),
                newIdentNode("internal")
              )
            )
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("initMyObj"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("MyObj"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("string"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkAsgn.newTree(
        newIdentNode("result"),
        nnkObjConstr.newTree(
          newIdentNode("MyObj"),
          nnkExprColonExpr.newTree(
            newIdentNode("internal"),
            nnkCall.newTree(
              newIdentNode("c_malloc"),
              newLit(126)
            )
          )
        )
      ),
      nnkIfStmt.newTree(
        nnkElifBranch.newTree(
          nnkInfix.newTree(
            newIdentNode("<"),
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("len")
            ),
            newLit(128)
          ),
          nnkStmtList.newTree(
            nnkCall.newTree(
              nnkDotExpr.newTree(
                nnkDotExpr.newTree(
                  newIdentNode("result"),
                  newIdentNode("internal")
                ),
                newIdentNode("copyMem")
              ),
              nnkDotExpr.newTree(
                nnkBracketExpr.newTree(
                  newIdentNode("x"),
                  newLit(0)
                ),
                newIdentNode("addr")
              ),
              nnkDotExpr.newTree(
                newIdentNode("x"),
                newIdentNode("len")
              )
            )
          )
        ),
        nnkElse.newTree(
          nnkStmtList.newTree(
            nnkRaiseStmt.newTree(
              nnkCall.newTree(
                newIdentNode("newException"),
                newIdentNode("MyError"),
                newLit("This is an error")
              )
            )
          )
        )
      )
    )
  ),
  nnkImportStmt.newTree(
    newIdentNode("strutils")
  ),
  nnkTryStmt.newTree(
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        nnkCall.newTree(
          newIdentNode("initMyObj"),
          newLit("Hello world")
        )
      ),
      nnkCommand.newTree(
        newIdentNode("echo"),
        nnkCall.newTree(
          newIdentNode("initMyObj"),
          nnkCall.newTree(
            nnkDotExpr.newTree(
              newLit("Hello world"),
              newIdentNode("repeat")
            ),
            newLit(128)
          )
        )
      )
    ),
    nnkExceptBranch.newTree(
      nnkInfix.newTree(
        newIdentNode("as"),
        newIdentNode("MyError"),
        newIdentNode("e")
      ),
      nnkStmtList.newTree(
        nnkCommand.newTree(
          newIdentNode("echo"),
          newLit("Got an error!")
        ),
        nnkCommand.newTree(
          newIdentNode("echo"),
          nnkDotExpr.newTree(
            newIdentNode("e"),
            newIdentNode("msg")
          )
        )
      )
    )
  )
)
1.0.0 👎 FAIL

Output

Error: Command failed: nim c --gc:arc -d:useMalloc --expandArc:initMyObj -d:nimArcDebug -d:nimArcIds  -d:nimAllocPagesViaMalloc -d:useSysAssert -d:useGcAssert -d:nimLeakDetector --debugger:native --debuginfo:on  -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim && valgrind /home/runner/work/Nim/Nim/temp
command line(1, 2) Error: invalid command line option: '--expandArc'

Stats

  • Started 2023-09-08T13:30:20
  • Finished 2023-09-08T13:30:20
  • Duration

IR

Compiled filesize 353.13 Kb (361,600 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
#define nimfr_(proc, file) \
  TFrame FR_; \
  FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
  #define nimfrs_(proc, file, slots, length) \
    struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename;NI len;VarSlot s[slots];} FR_; \
    FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
  #define nimln_(n) \
    FR_.line = n;
  #define nimlf_(n, file) \
    FR_.line = n; FR_.filename = file;
typedef struct tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
typedef struct tyObject_MyError__fVAoPZxkmyx7potpEdBUTw tyObject_MyError__fVAoPZxkmyx7potpEdBUTw;
typedef struct tyObject_CatchableError__plmui9cLQDf1IsFzhQAAHyg tyObject_CatchableError__plmui9cLQDf1IsFzhQAAHyg;
typedef struct Exception Exception;
typedef struct RootObj RootObj;
typedef struct TNimTypeV2 TNimTypeV2;
typedef struct tySequence__2ALwPJKv8Nz8mMm4Hy9crdw tySequence__2ALwPJKv8Nz8mMm4Hy9crdw;
typedef struct tySequence__2ALwPJKv8Nz8mMm4Hy9crdw_Content tySequence__2ALwPJKv8Nz8mMm4Hy9crdw_Content;
typedef struct tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag;
typedef struct tyObject_StackTraceEntry__nOjYJiLBbFH64nNmW1UArA tyObject_StackTraceEntry__nOjYJiLBbFH64nNmW1UArA;
struct tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw {	void* internal;
};
struct NimStrPayload {	NI cap;
	NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {	NI len;
	NimStrPayload* p;
};
typedef NimStringV2 tyArray__nHXaesL0DJZHyVS07ARPRA[1];
struct TNimTypeV2 {	void* destructor;
	NI size;
	NI16 align;
	NI16 depth;
	NU32* display;
	NCSTRING name;
	void* traceImpl;
	void* typeInfoV1;
	NI flags;
};
struct RootObj {TNimTypeV2* m_type;};
struct tySequence__2ALwPJKv8Nz8mMm4Hy9crdw {
  NI len; tySequence__2ALwPJKv8Nz8mMm4Hy9crdw_Content* p;
};
struct Exception {  RootObj Sup;	Exception* parent;
	NCSTRING name;
	NimStringV2 message;
	tySequence__2ALwPJKv8Nz8mMm4Hy9crdw trace;
	Exception* up;
};
struct tyObject_CatchableError__plmui9cLQDf1IsFzhQAAHyg {  Exception Sup;};
struct tyObject_MyError__fVAoPZxkmyx7potpEdBUTw {  tyObject_CatchableError__plmui9cLQDf1IsFzhQAAHyg Sup;};
struct tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag {	NI rc;
	NI refId;
};
struct tyObject_StackTraceEntry__nOjYJiLBbFH64nNmW1UArA {	NCSTRING procname;
	NI line;
	NCSTRING filename;
};
struct tySequence__2ALwPJKv8Nz8mMm4Hy9crdw_Content { NI cap; tyObject_StackTraceEntry__nOjYJiLBbFH64nNmW1UArA data[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(NimStringV2, dollar___temp_u92)(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw x_p0);
N_LIB_PRIVATE N_NIMCALL(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw, initMyObj__temp_u10)(NimStringV2 x_p0);
static N_INLINE(void, copyMem__system_u1745)(void* dest_p0, void* source_p1, NI size_p2);
static N_INLINE(void, nimCopyMem)(void* dest_p0, void* source_p1, NI size_p2);
N_LIB_PRIVATE N_NOINLINE(void, raiseIndexError2)(NI i_p0, NI n_p1);
N_LIB_PRIVATE N_NOINLINE(void, raiseRangeErrorI)(NI64 i_p0, NI64 a_p1, NI64 b_p2);
N_LIB_PRIVATE N_NIMCALL(void*, nimNewObj)(NI size_p0, NI alignment_p1);
N_LIB_PRIVATE N_NIMCALL(void, rttiDestroy__temp_u127)(void* dest_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u27)(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* dest_p0);
static N_INLINE(NIM_BOOL, nimDecRefIsLast)(void* p_p0);
static N_INLINE(NI, minuspercent___system_u810)(NI x_p0, NI y_p1);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4156)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, writeStackTrace__system_u2550)(void);
N_LIB_PRIVATE N_NOINLINE(void, raiseOverflow)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimDestroyAndDispose)(void* p_p0);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___stdZassertions_u82)(tySequence__2ALwPJKv8Nz8mMm4Hy9crdw dest_p0);
N_LIB_PRIVATE N_NIMCALL(void, raiseExceptionEx)(Exception* e_p0, NCSTRING ename_p1, NCSTRING procname_p2, NCSTRING filename_p3, NI line_p4);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringV2* args_p0, NI args_p0Len_0);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, nsuRepeatStr)(NimStringV2 s_p0, NI n_p1);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u5)(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw x_p0);
static N_INLINE(NIM_BOOL, isObjDisplayCheck)(TNimTypeV2* source_p0, NI16 targetDepth_p1, NU32 token_p2);
static N_INLINE(Exception*, nimBorrowCurrentException)(void);
static N_INLINE(Exception*, getCurrentException)(void);
N_LIB_PRIVATE N_NIMCALL(void, eqcopy___stdZtypedthreads_u195)(Exception** dest_p0, Exception* src_p1);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u55)(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* dest_p0);
static N_INLINE(void, popCurrentException)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
N_LIB_PRIVATE TNimTypeV2 NTIv2__fVAoPZxkmyx7potpEdBUTw_;
static const struct {
  NI cap; NIM_CHAR data[16+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_4 = { 16 | NIM_STRLIT_FLAG, "This is an error" };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_5 = {16, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_4};
static const struct {
  NI cap; NIM_CHAR data[11+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_6 = { 11 | NIM_STRLIT_FLAG, "Hello world" };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_7 = {11, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_6};
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_8 = {11, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_6};
static const struct {
  NI cap; NIM_CHAR data[13+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_10 = { 13 | NIM_STRLIT_FLAG, "Got an error!" };
static NIM_CONST tyArray__nHXaesL0DJZHyVS07ARPRA TM__SRd76hP9cMfCzdUO857UhQQ_9 = {{13, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_10}}
;
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u3964;
extern NIM_THREADVAR TFrame* framePtr__system_u3602;
static NIM_CONST NU32 TM__SRd76hP9cMfCzdUO857UhQQ_3[4] = {3701606400, 1285336064, 1504611072, 1344814336};
N_LIB_PRIVATE TNimTypeV2 NTIv2__fVAoPZxkmyx7potpEdBUTw_ = {.destructor = (void*)rttiDestroy__temp_u127, .size = sizeof(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw), .align = (NI16) NIM_ALIGNOF(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw), .depth = 3, .display = TM__SRd76hP9cMfCzdUO857UhQQ_3, .traceImpl = (void*)NIM_NIL, .flags = 0};
extern NIM_THREADVAR Exception* currException__system_u3604;
#line 19 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/memory.nim"
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2) {	void* T1_;
#line 21
	T1_ = (void*)0;	T1_ = memset(a_p0, v_p1, ((size_t) (size_p2)));}
#line 423 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/excpt.nim"
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {	NIM_BOOL* result;	result = (NIM_BOOL*)0;
#line 424
	result = (&nimInErrorMode__system_u3964);	return result;}
#line 30 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/memory.nim"
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1) {NIM_BOOL* nimErr_;{nimErr_ = nimErrorFlag();
#line 31
	nimSetMem__systemZmemory_u7(p_p0, ((int)0), size_p1);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;	}BeforeRet_: ;
}
#line 8 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/memory.nim"
static N_INLINE(void, nimCopyMem)(void* dest_p0, void* source_p1, NI size_p2) {	void* T1_;
#line 10
	T1_ = (void*)0;	T1_ = memcpy(dest_p0, source_p1, ((size_t) (size_p2)));}
#line 2016 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim"
static N_INLINE(void, copyMem__system_u1745)(void* dest_p0, void* source_p1, NI size_p2) {
#line 2017
	nimCopyMem(dest_p0, source_p1, size_p2);
}
#line 549 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/excpt.nim"
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
#line 550
	{		if (!(framePtr__system_u3602 == ((TFrame*) NIM_NIL))) goto LA3_;
#line 551
		(*s_p0).calldepth = ((NI16)0);	}
	goto LA1_;
LA3_: ;
	{
#line 554
		(*s_p0).calldepth = (NI16)((*framePtr__system_u3602).calldepth + ((NI16)1));	}
LA1_: ;
#line 556
	(*s_p0).prev = framePtr__system_u3602;
#line 557
	framePtr__system_u3602 = s_p0;
#line 558
	{		if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
		callDepthLimitReached__system_u4156();
	}
LA8_: ;
}
#line 99 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/excpt.nim"
static N_INLINE(void, popFrame)(void) {
#line 100
	framePtr__system_u3602 = (*framePtr__system_u3602).prev;}
#line 363 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arithmetics.nim"
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;
#line 364
#line 368
	result = ((NI) ((NU)((NU64)(((NU) (x_p0))) - (NU64)(((NU) (y_p1))))));	popFrame();	return result;}
#line 196 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arc.nim"
static N_INLINE(NIM_BOOL, nimDecRefIsLast)(void* p_p0) {	NIM_BOOL result;	nimfr_("nimDecRefIsLast", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arc.nim");{	result = (NIM_BOOL)0;
#line 197
	{		
#line 202
int colontmpD_;		
#line 198
tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag* cell;		NI T5_;		if (!!((p_p0 == NIM_NIL))) goto LA3_;
		colontmpD_ = (int)0;
#line 43
		T5_ = (NI)0;		T5_ = minuspercent___system_u810(((NI) (ptrdiff_t) (p_p0)), ((NI)16));		cell = ((tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag*) (T5_));
#line 201
		{			if (!((*cell).refId == ((NI)20))) goto LA8_;
#line 202
			writeStackTrace__system_u2550();
#line 203
			colontmpD_ = fprintf(stderr, "[DecRef] %p %ld\012", p_p0, (NI)((NI64)((*cell).rc) >> (NU64)(((NI)3))));		}
LA8_: ;
#line 205
		{			if (!((NI)((NI64)((*cell).rc) >> (NU64)(((NI)3))) == ((NI)0))) goto LA12_;
#line 206
			result = NIM_TRUE;		}
		goto LA10_;
LA12_: ;
		{			NI TM__SRd76hP9cMfCzdUO857UhQQ_2;
#line 210
			if (nimSubInt((*cell).rc, ((NI)8), &TM__SRd76hP9cMfCzdUO857UhQQ_2)) { raiseOverflow(); goto BeforeRet_;			};			(*cell).rc = (NI)(TM__SRd76hP9cMfCzdUO857UhQQ_2);		}
LA10_: ;
	}
LA3_: ;
	}BeforeRet_: ;
	popFrame();	return result;}
#line 18 "/home/runner/work/Nim/Nim/temp.nim"
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u27)(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* dest_p0) {	{		NIM_BOOL T3_;		T3_ = (NIM_BOOL)0;		T3_ = nimDecRefIsLast((*dest_p0).Sup.Sup.parent);		if (!T3_) goto LA4_;
		nimDestroyAndDispose((*dest_p0).Sup.Sup.parent);
	}
LA4_: ;
	if ((*dest_p0).Sup.Sup.message.p && !((*dest_p0).Sup.Sup.message.p->cap & NIM_STRLIT_FLAG)) { deallocShared((*dest_p0).Sup.Sup.message.p);}	eqdestroy___stdZassertions_u82((*dest_p0).Sup.Sup.trace);
	{		NIM_BOOL T8_;		T8_ = (NIM_BOOL)0;		T8_ = nimDecRefIsLast((*dest_p0).Sup.Sup.up);		if (!T8_) goto LA9_;
		nimDestroyAndDispose((*dest_p0).Sup.Sup.up);
	}
LA9_: ;
}
#line 18 "/home/runner/work/Nim/Nim/temp.nim"
N_LIB_PRIVATE N_NIMCALL(void, rttiDestroy__temp_u127)(void* dest_p0) {NIM_BOOL* nimErr_;{nimErr_ = nimErrorFlag();	eqdestroy___temp_u27(((tyObject_MyError__fVAoPZxkmyx7potpEdBUTw*) (dest_p0)));
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;	}BeforeRet_: ;
}
#line 13 "/home/runner/work/Nim/Nim/temp.nim"
N_LIB_PRIVATE N_NIMCALL(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw, initMyObj__temp_u10)(NimStringV2 x_p0) {	tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw result;	nimfr_("initMyObj", "/home/runner/work/Nim/Nim/temp.nim");{	nimZeroMem((void*)(&result), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));
#line 14
	nimZeroMem((void*)(&result), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));	result.internal = malloc(((size_t)126));
#line 15
	{		if (!(x_p0.len < ((NI)128))) goto LA3_;
#line 16
		if (((NI)0) < 0 || ((NI)0) >= x_p0.len){ raiseIndexError2(((NI)0),x_p0.len-1); goto BeforeRet_;		}		if ((x_p0.len) < ((NI)0) || (x_p0.len) > ((NI)IL64(9223372036854775807))){ raiseRangeErrorI(x_p0.len, ((NI)0), ((NI)IL64(9223372036854775807))); goto BeforeRet_;		}		copyMem__system_u1745(result.internal, ((void*) ((&x_p0.p->data[((NI)0)]))), ((NI) (x_p0.len)));
	}
	goto LA1_;
LA3_: ;
	{		tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* T6_;		T6_ = NIM_NIL;		T6_ = (tyObject_MyError__fVAoPZxkmyx7potpEdBUTw*) nimNewObj(sizeof(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw), NIM_ALIGNOF(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw));		(*T6_).Sup.Sup.Sup.m_type = (&NTIv2__fVAoPZxkmyx7potpEdBUTw_);		(*T6_).Sup.Sup.name = "MyError";		(*T6_).Sup.Sup.message = TM__SRd76hP9cMfCzdUO857UhQQ_5;		(*T6_).Sup.Sup.parent = ((Exception*) NIM_NIL);
#line 18
		raiseExceptionEx((Exception*)T6_, "MyError", "initMyObj", "/home/runner/work/Nim/Nim/temp.nim", 18);goto BeforeRet_;	}
LA1_: ;
	}BeforeRet_: ;
	popFrame();	return result;}
#line 6 "/home/runner/work/Nim/Nim/temp.nim"
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u5)(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw x_p0) {	nimfr_("=destroy", "/home/runner/work/Nim/Nim/temp.nim");{
#line 7
	{		if (!(x_p0.internal == 0)) goto LA3_;
		goto BeforeRet_;
	}
LA3_: ;
#line 8
	free(x_p0.internal);
	}BeforeRet_: ;
	popFrame();}
#line 237 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arc.nim"
static N_INLINE(NIM_BOOL, isObjDisplayCheck)(TNimTypeV2* source_p0, NI16 targetDepth_p1, NU32 token_p2) {	NIM_BOOL result;	NIM_BOOL T1_;	nimfr_("isObjDisplayCheck", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arc.nim");	result = (NIM_BOOL)0;
#line 238
	T1_ = (NIM_BOOL)0;	T1_ = (targetDepth_p1 <= (*source_p0).depth);	if (!(T1_)) goto LA2_;
	T1_ = ((*source_p0).display[targetDepth_p1] == token_p2);LA2_: ;
	result = T1_;	popFrame();	return result;}
#line 2209 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim"
static N_INLINE(Exception*, nimBorrowCurrentException)(void) {	Exception* result;	nimfr_("nimBorrowCurrentException", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim");	result = NIM_NIL;
#line 2212
	result = currException__system_u3604;	popFrame();	return result;}
#line 2205 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim"
static N_INLINE(Exception*, getCurrentException)(void) {	Exception* result;	nimfr_("getCurrentException", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim");	result = NIM_NIL;
#line 247 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/std/typedthreads.nim"
	eqcopy___stdZtypedthreads_u195(&result, currException__system_u3604);
	popFrame();	return result;}
#line 18 "/home/runner/work/Nim/Nim/temp.nim"
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u55)(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* dest_p0) {	{		NIM_BOOL T3_;		T3_ = (NIM_BOOL)0;		T3_ = nimDecRefIsLast(dest_p0);		if (!T3_) goto LA4_;
		nimDestroyAndDispose(dest_p0);
	}
LA4_: ;
}
#line 137 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/excpt.nim"
static N_INLINE(void, popCurrentException)(void) {
#line 247 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/std/typedthreads.nim"
	eqcopy___stdZtypedthreads_u195(&currException__system_u3604, (*currException__system_u3604).up);
}
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) {
#line 999999 "generated_not_to_break_here"
{
#line 21 "/home/runner/work/Nim/Nim/temp.nim"
tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw colontmpD_;	NimStringV2 colontmpD__2;	
#line 22
NimStringV2 colontmpD__3;	tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw colontmpD__4;	NimStringV2 colontmpD__5;	tyArray__nHXaesL0DJZHyVS07ARPRA T3_;	tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw T4_;	NimStringV2 T5_;	tyArray__nHXaesL0DJZHyVS07ARPRA T6_;	NimStringV2 T7_;	tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw T8_;	NimStringV2 T9_;NIM_BOOL oldNimErrFin2_;NIM_BOOL oldNimErrFin15_;NIM_BOOL* nimErr_;	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");nimErr_ = nimErrorFlag();	nimZeroMem((void*)(&colontmpD_), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));	colontmpD__2.len = 0; colontmpD__2.p = NIM_NIL;	colontmpD__3.len = 0; colontmpD__3.p = NIM_NIL;	nimZeroMem((void*)(&colontmpD__4), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));	colontmpD__5.len = 0; colontmpD__5.p = NIM_NIL;
#line 21
	nimZeroMem((void*)(&T4_), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));	T4_ = initMyObj__temp_u10(TM__SRd76hP9cMfCzdUO857UhQQ_7);	if (NIM_UNLIKELY(*nimErr_)) goto LA2_;	colontmpD_ = T4_;	T5_.len = 0; T5_.p = NIM_NIL;	T5_ = dollar___temp_u92(colontmpD_);	if (NIM_UNLIKELY(*nimErr_)) goto LA2_;	colontmpD__2 = T5_;	T3_[0] = colontmpD__2;	echoBinSafe(T3_, 1);
#line 22
	T7_.len = 0; T7_.p = NIM_NIL;	T7_ = nsuRepeatStr(TM__SRd76hP9cMfCzdUO857UhQQ_8, ((NI)128));	if (NIM_UNLIKELY(*nimErr_)) goto LA2_;	colontmpD__3 = T7_;	nimZeroMem((void*)(&T8_), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));	T8_ = initMyObj__temp_u10(colontmpD__3);	if (NIM_UNLIKELY(*nimErr_)) goto LA2_;	colontmpD__4 = T8_;	T9_.len = 0; T9_.p = NIM_NIL;	T9_ = dollar___temp_u92(colontmpD__4);	if (NIM_UNLIKELY(*nimErr_)) goto LA2_;	colontmpD__5 = T9_;	T6_[0] = colontmpD__5;	echoBinSafe(T6_, 1);	{		LA2_:;	}
	{		oldNimErrFin2_ = *nimErr_; *nimErr_ = NIM_FALSE;
#line 370 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim"
		if (colontmpD__5.p && !(colontmpD__5.p->cap & NIM_STRLIT_FLAG)) { deallocShared(colontmpD__5.p);}
#line 6 "/home/runner/work/Nim/Nim/temp.nim"
		eqdestroy___temp_u5(colontmpD__4);
		if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
#line 370 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim"
		if (colontmpD__3.p && !(colontmpD__3.p->cap & NIM_STRLIT_FLAG)) { deallocShared(colontmpD__3.p);}		if (colontmpD__2.p && !(colontmpD__2.p->cap & NIM_STRLIT_FLAG)) { deallocShared(colontmpD__2.p);}
#line 6 "/home/runner/work/Nim/Nim/temp.nim"
		eqdestroy___temp_u5(colontmpD_);
		if (NIM_UNLIKELY(*nimErr_)) goto LA1_;		*nimErr_ = oldNimErrFin2_;	}
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;	if (NIM_UNLIKELY(*nimErr_)) {		LA1_:;		if (isObjDisplayCheck(nimBorrowCurrentException()->Sup.m_type, 3, 1344814336)) {			
#line 23
tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* e;			Exception* T16_;			tyArray__nHXaesL0DJZHyVS07ARPRA T17_;			*nimErr_ = NIM_FALSE;			e = NIM_NIL;
#line 24
			T16_ = NIM_NIL;			T16_ = getCurrentException();			e = ((tyObject_MyError__fVAoPZxkmyx7potpEdBUTw*) (T16_));
#line 24 "/home/runner/work/Nim/Nim/temp.nim"
			echoBinSafe(TM__SRd76hP9cMfCzdUO857UhQQ_9, 1);
#line 25
			T17_[0] = (*e).Sup.Sup.message;			echoBinSafe(T17_, 1);			{				LA15_:;			}
			{				oldNimErrFin15_ = *nimErr_; *nimErr_ = NIM_FALSE;
#line 18
				eqdestroy___temp_u55(e);
				if (NIM_UNLIKELY(*nimErr_)) goto LA13_;				*nimErr_ = oldNimErrFin15_;			}
			if (NIM_UNLIKELY(*nimErr_)) goto LA13_;			popCurrentException();			LA13_:;		}
	}
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;	BeforeRet_: ;
	nimTestErrorFlag();	popFrame();}
}

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("system"),
      newIdentNode("ansi_c")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("MyError"),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        nnkOfInherit.newTree(
          newIdentNode("CatchableError")
        ),
        newEmptyNode()
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("MyObj"),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("internal"),
            newIdentNode("pointer"),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    nnkAccQuoted.newTree(
      newIdentNode("="),
      newIdentNode("destroy")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("MyObj"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkIfStmt.newTree(
        nnkElifBranch.newTree(
          nnkDotExpr.newTree(
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("internal")
            ),
            newIdentNode("isNil")
          ),
          nnkStmtList.newTree(
            nnkReturnStmt.newTree(
              newEmptyNode()
            )
          )
        )
      ),
      nnkDotExpr.newTree(
        nnkDotExpr.newTree(
          newIdentNode("x"),
          newIdentNode("internal")
        ),
        newIdentNode("c_free")
      )
    )
  ),
  nnkProcDef.newTree(
    nnkAccQuoted.newTree(
      newIdentNode("="),
      newIdentNode("copy")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkVarTy.newTree(
          newIdentNode("MyObj")
        ),
        newEmptyNode()
      ),
      nnkIdentDefs.newTree(
        newIdentNode("y"),
        newIdentNode("MyObj"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkIfStmt.newTree(
        nnkElifBranch.newTree(
          nnkInfix.newTree(
            newIdentNode("!="),
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("internal")
            ),
            nnkDotExpr.newTree(
              newIdentNode("y"),
              newIdentNode("internal")
            )
          ),
          nnkStmtList.newTree(
            nnkDotExpr.newTree(
              nnkDotExpr.newTree(
                newIdentNode("x"),
                newIdentNode("internal")
              ),
              newIdentNode("c_free")
            ),
            nnkAsgn.newTree(
              nnkDotExpr.newTree(
                newIdentNode("x"),
                newIdentNode("internal")
              ),
              nnkDotExpr.newTree(
                newIdentNode("y"),
                newIdentNode("internal")
              )
            )
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("initMyObj"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("MyObj"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("string"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkAsgn.newTree(
        newIdentNode("result"),
        nnkObjConstr.newTree(
          newIdentNode("MyObj"),
          nnkExprColonExpr.newTree(
            newIdentNode("internal"),
            nnkCall.newTree(
              newIdentNode("c_malloc"),
              newLit(126)
            )
          )
        )
      ),
      nnkIfStmt.newTree(
        nnkElifBranch.newTree(
          nnkInfix.newTree(
            newIdentNode("<"),
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("len")
            ),
            newLit(128)
          ),
          nnkStmtList.newTree(
            nnkCall.newTree(
              nnkDotExpr.newTree(
                nnkDotExpr.newTree(
                  newIdentNode("result"),
                  newIdentNode("internal")
                ),
                newIdentNode("copyMem")
              ),
              nnkDotExpr.newTree(
                nnkBracketExpr.newTree(
                  newIdentNode("x"),
                  newLit(0)
                ),
                newIdentNode("addr")
              ),
              nnkDotExpr.newTree(
                newIdentNode("x"),
                newIdentNode("len")
              )
            )
          )
        ),
        nnkElse.newTree(
          nnkStmtList.newTree(
            nnkRaiseStmt.newTree(
              nnkCall.newTree(
                newIdentNode("newException"),
                newIdentNode("MyError"),
                newLit("This is an error")
              )
            )
          )
        )
      )
    )
  ),
  nnkImportStmt.newTree(
    newIdentNode("strutils")
  ),
  nnkTryStmt.newTree(
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        nnkCall.newTree(
          newIdentNode("initMyObj"),
          newLit("Hello world")
        )
      ),
      nnkCommand.newTree(
        newIdentNode("echo"),
        nnkCall.newTree(
          newIdentNode("initMyObj"),
          nnkCall.newTree(
            nnkDotExpr.newTree(
              newLit("Hello world"),
              newIdentNode("repeat")
            ),
            newLit(128)
          )
        )
      )
    ),
    nnkExceptBranch.newTree(
      nnkInfix.newTree(
        newIdentNode("as"),
        newIdentNode("MyError"),
        newIdentNode("e")
      ),
      nnkStmtList.newTree(
        nnkCommand.newTree(
          newIdentNode("echo"),
          newLit("Got an error!")
        ),
        nnkCommand.newTree(
          newIdentNode("echo"),
          nnkDotExpr.newTree(
            newIdentNode("e"),
            newIdentNode("msg")
          )
        )
      )
    )
  )
)
0.20.2 👎 FAIL

Output

Error: Command failed: nim c --gc:arc -d:useMalloc --expandArc:initMyObj -d:nimArcDebug -d:nimArcIds  -d:nimAllocPagesViaMalloc -d:useSysAssert -d:useGcAssert -d:nimLeakDetector --debugger:native --debuginfo:on  -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim && valgrind /home/runner/work/Nim/Nim/temp
command line(1, 2) Error: 'none', 'boehm' or 'refc' expected, but 'arc' found

Stats

  • Started 2023-09-08T13:30:30
  • Finished 2023-09-08T13:30:30
  • Duration

IR

Compiled filesize 353.13 Kb (361,600 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
#define nimfr_(proc, file) \
  TFrame FR_; \
  FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
  #define nimfrs_(proc, file, slots, length) \
    struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename;NI len;VarSlot s[slots];} FR_; \
    FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
  #define nimln_(n) \
    FR_.line = n;
  #define nimlf_(n, file) \
    FR_.line = n; FR_.filename = file;
typedef struct tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
typedef struct tyObject_MyError__fVAoPZxkmyx7potpEdBUTw tyObject_MyError__fVAoPZxkmyx7potpEdBUTw;
typedef struct tyObject_CatchableError__plmui9cLQDf1IsFzhQAAHyg tyObject_CatchableError__plmui9cLQDf1IsFzhQAAHyg;
typedef struct Exception Exception;
typedef struct RootObj RootObj;
typedef struct TNimTypeV2 TNimTypeV2;
typedef struct tySequence__2ALwPJKv8Nz8mMm4Hy9crdw tySequence__2ALwPJKv8Nz8mMm4Hy9crdw;
typedef struct tySequence__2ALwPJKv8Nz8mMm4Hy9crdw_Content tySequence__2ALwPJKv8Nz8mMm4Hy9crdw_Content;
typedef struct tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag;
typedef struct tyObject_StackTraceEntry__nOjYJiLBbFH64nNmW1UArA tyObject_StackTraceEntry__nOjYJiLBbFH64nNmW1UArA;
struct tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw {	void* internal;
};
struct NimStrPayload {	NI cap;
	NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {	NI len;
	NimStrPayload* p;
};
typedef NimStringV2 tyArray__nHXaesL0DJZHyVS07ARPRA[1];
struct TNimTypeV2 {	void* destructor;
	NI size;
	NI16 align;
	NI16 depth;
	NU32* display;
	NCSTRING name;
	void* traceImpl;
	void* typeInfoV1;
	NI flags;
};
struct RootObj {TNimTypeV2* m_type;};
struct tySequence__2ALwPJKv8Nz8mMm4Hy9crdw {
  NI len; tySequence__2ALwPJKv8Nz8mMm4Hy9crdw_Content* p;
};
struct Exception {  RootObj Sup;	Exception* parent;
	NCSTRING name;
	NimStringV2 message;
	tySequence__2ALwPJKv8Nz8mMm4Hy9crdw trace;
	Exception* up;
};
struct tyObject_CatchableError__plmui9cLQDf1IsFzhQAAHyg {  Exception Sup;};
struct tyObject_MyError__fVAoPZxkmyx7potpEdBUTw {  tyObject_CatchableError__plmui9cLQDf1IsFzhQAAHyg Sup;};
struct tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag {	NI rc;
	NI refId;
};
struct tyObject_StackTraceEntry__nOjYJiLBbFH64nNmW1UArA {	NCSTRING procname;
	NI line;
	NCSTRING filename;
};
struct tySequence__2ALwPJKv8Nz8mMm4Hy9crdw_Content { NI cap; tyObject_StackTraceEntry__nOjYJiLBbFH64nNmW1UArA data[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(NimStringV2, dollar___temp_u92)(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw x_p0);
N_LIB_PRIVATE N_NIMCALL(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw, initMyObj__temp_u10)(NimStringV2 x_p0);
static N_INLINE(void, copyMem__system_u1745)(void* dest_p0, void* source_p1, NI size_p2);
static N_INLINE(void, nimCopyMem)(void* dest_p0, void* source_p1, NI size_p2);
N_LIB_PRIVATE N_NOINLINE(void, raiseIndexError2)(NI i_p0, NI n_p1);
N_LIB_PRIVATE N_NOINLINE(void, raiseRangeErrorI)(NI64 i_p0, NI64 a_p1, NI64 b_p2);
N_LIB_PRIVATE N_NIMCALL(void*, nimNewObj)(NI size_p0, NI alignment_p1);
N_LIB_PRIVATE N_NIMCALL(void, rttiDestroy__temp_u127)(void* dest_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u27)(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* dest_p0);
static N_INLINE(NIM_BOOL, nimDecRefIsLast)(void* p_p0);
static N_INLINE(NI, minuspercent___system_u810)(NI x_p0, NI y_p1);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4156)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, writeStackTrace__system_u2550)(void);
N_LIB_PRIVATE N_NOINLINE(void, raiseOverflow)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimDestroyAndDispose)(void* p_p0);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___stdZassertions_u82)(tySequence__2ALwPJKv8Nz8mMm4Hy9crdw dest_p0);
N_LIB_PRIVATE N_NIMCALL(void, raiseExceptionEx)(Exception* e_p0, NCSTRING ename_p1, NCSTRING procname_p2, NCSTRING filename_p3, NI line_p4);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringV2* args_p0, NI args_p0Len_0);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, nsuRepeatStr)(NimStringV2 s_p0, NI n_p1);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u5)(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw x_p0);
static N_INLINE(NIM_BOOL, isObjDisplayCheck)(TNimTypeV2* source_p0, NI16 targetDepth_p1, NU32 token_p2);
static N_INLINE(Exception*, nimBorrowCurrentException)(void);
static N_INLINE(Exception*, getCurrentException)(void);
N_LIB_PRIVATE N_NIMCALL(void, eqcopy___stdZtypedthreads_u195)(Exception** dest_p0, Exception* src_p1);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u55)(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* dest_p0);
static N_INLINE(void, popCurrentException)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
N_LIB_PRIVATE TNimTypeV2 NTIv2__fVAoPZxkmyx7potpEdBUTw_;
static const struct {
  NI cap; NIM_CHAR data[16+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_4 = { 16 | NIM_STRLIT_FLAG, "This is an error" };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_5 = {16, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_4};
static const struct {
  NI cap; NIM_CHAR data[11+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_6 = { 11 | NIM_STRLIT_FLAG, "Hello world" };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_7 = {11, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_6};
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_8 = {11, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_6};
static const struct {
  NI cap; NIM_CHAR data[13+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_10 = { 13 | NIM_STRLIT_FLAG, "Got an error!" };
static NIM_CONST tyArray__nHXaesL0DJZHyVS07ARPRA TM__SRd76hP9cMfCzdUO857UhQQ_9 = {{13, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_10}}
;
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u3964;
extern NIM_THREADVAR TFrame* framePtr__system_u3602;
static NIM_CONST NU32 TM__SRd76hP9cMfCzdUO857UhQQ_3[4] = {3701606400, 1285336064, 1504611072, 1344814336};
N_LIB_PRIVATE TNimTypeV2 NTIv2__fVAoPZxkmyx7potpEdBUTw_ = {.destructor = (void*)rttiDestroy__temp_u127, .size = sizeof(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw), .align = (NI16) NIM_ALIGNOF(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw), .depth = 3, .display = TM__SRd76hP9cMfCzdUO857UhQQ_3, .traceImpl = (void*)NIM_NIL, .flags = 0};
extern NIM_THREADVAR Exception* currException__system_u3604;
#line 19 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/memory.nim"
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2) {	void* T1_;
#line 21
	T1_ = (void*)0;	T1_ = memset(a_p0, v_p1, ((size_t) (size_p2)));}
#line 423 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/excpt.nim"
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {	NIM_BOOL* result;	result = (NIM_BOOL*)0;
#line 424
	result = (&nimInErrorMode__system_u3964);	return result;}
#line 30 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/memory.nim"
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1) {NIM_BOOL* nimErr_;{nimErr_ = nimErrorFlag();
#line 31
	nimSetMem__systemZmemory_u7(p_p0, ((int)0), size_p1);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;	}BeforeRet_: ;
}
#line 8 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/memory.nim"
static N_INLINE(void, nimCopyMem)(void* dest_p0, void* source_p1, NI size_p2) {	void* T1_;
#line 10
	T1_ = (void*)0;	T1_ = memcpy(dest_p0, source_p1, ((size_t) (size_p2)));}
#line 2016 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim"
static N_INLINE(void, copyMem__system_u1745)(void* dest_p0, void* source_p1, NI size_p2) {
#line 2017
	nimCopyMem(dest_p0, source_p1, size_p2);
}
#line 549 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/excpt.nim"
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
#line 550
	{		if (!(framePtr__system_u3602 == ((TFrame*) NIM_NIL))) goto LA3_;
#line 551
		(*s_p0).calldepth = ((NI16)0);	}
	goto LA1_;
LA3_: ;
	{
#line 554
		(*s_p0).calldepth = (NI16)((*framePtr__system_u3602).calldepth + ((NI16)1));	}
LA1_: ;
#line 556
	(*s_p0).prev = framePtr__system_u3602;
#line 557
	framePtr__system_u3602 = s_p0;
#line 558
	{		if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
		callDepthLimitReached__system_u4156();
	}
LA8_: ;
}
#line 99 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/excpt.nim"
static N_INLINE(void, popFrame)(void) {
#line 100
	framePtr__system_u3602 = (*framePtr__system_u3602).prev;}
#line 363 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arithmetics.nim"
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;
#line 364
#line 368
	result = ((NI) ((NU)((NU64)(((NU) (x_p0))) - (NU64)(((NU) (y_p1))))));	popFrame();	return result;}
#line 196 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arc.nim"
static N_INLINE(NIM_BOOL, nimDecRefIsLast)(void* p_p0) {	NIM_BOOL result;	nimfr_("nimDecRefIsLast", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arc.nim");{	result = (NIM_BOOL)0;
#line 197
	{		
#line 202
int colontmpD_;		
#line 198
tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag* cell;		NI T5_;		if (!!((p_p0 == NIM_NIL))) goto LA3_;
		colontmpD_ = (int)0;
#line 43
		T5_ = (NI)0;		T5_ = minuspercent___system_u810(((NI) (ptrdiff_t) (p_p0)), ((NI)16));		cell = ((tyObject_RefHeader__6F2b1ehFhXQfpzB3oYziag*) (T5_));
#line 201
		{			if (!((*cell).refId == ((NI)20))) goto LA8_;
#line 202
			writeStackTrace__system_u2550();
#line 203
			colontmpD_ = fprintf(stderr, "[DecRef] %p %ld\012", p_p0, (NI)((NI64)((*cell).rc) >> (NU64)(((NI)3))));		}
LA8_: ;
#line 205
		{			if (!((NI)((NI64)((*cell).rc) >> (NU64)(((NI)3))) == ((NI)0))) goto LA12_;
#line 206
			result = NIM_TRUE;		}
		goto LA10_;
LA12_: ;
		{			NI TM__SRd76hP9cMfCzdUO857UhQQ_2;
#line 210
			if (nimSubInt((*cell).rc, ((NI)8), &TM__SRd76hP9cMfCzdUO857UhQQ_2)) { raiseOverflow(); goto BeforeRet_;			};			(*cell).rc = (NI)(TM__SRd76hP9cMfCzdUO857UhQQ_2);		}
LA10_: ;
	}
LA3_: ;
	}BeforeRet_: ;
	popFrame();	return result;}
#line 18 "/home/runner/work/Nim/Nim/temp.nim"
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u27)(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* dest_p0) {	{		NIM_BOOL T3_;		T3_ = (NIM_BOOL)0;		T3_ = nimDecRefIsLast((*dest_p0).Sup.Sup.parent);		if (!T3_) goto LA4_;
		nimDestroyAndDispose((*dest_p0).Sup.Sup.parent);
	}
LA4_: ;
	if ((*dest_p0).Sup.Sup.message.p && !((*dest_p0).Sup.Sup.message.p->cap & NIM_STRLIT_FLAG)) { deallocShared((*dest_p0).Sup.Sup.message.p);}	eqdestroy___stdZassertions_u82((*dest_p0).Sup.Sup.trace);
	{		NIM_BOOL T8_;		T8_ = (NIM_BOOL)0;		T8_ = nimDecRefIsLast((*dest_p0).Sup.Sup.up);		if (!T8_) goto LA9_;
		nimDestroyAndDispose((*dest_p0).Sup.Sup.up);
	}
LA9_: ;
}
#line 18 "/home/runner/work/Nim/Nim/temp.nim"
N_LIB_PRIVATE N_NIMCALL(void, rttiDestroy__temp_u127)(void* dest_p0) {NIM_BOOL* nimErr_;{nimErr_ = nimErrorFlag();	eqdestroy___temp_u27(((tyObject_MyError__fVAoPZxkmyx7potpEdBUTw*) (dest_p0)));
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;	}BeforeRet_: ;
}
#line 13 "/home/runner/work/Nim/Nim/temp.nim"
N_LIB_PRIVATE N_NIMCALL(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw, initMyObj__temp_u10)(NimStringV2 x_p0) {	tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw result;	nimfr_("initMyObj", "/home/runner/work/Nim/Nim/temp.nim");{	nimZeroMem((void*)(&result), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));
#line 14
	nimZeroMem((void*)(&result), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));	result.internal = malloc(((size_t)126));
#line 15
	{		if (!(x_p0.len < ((NI)128))) goto LA3_;
#line 16
		if (((NI)0) < 0 || ((NI)0) >= x_p0.len){ raiseIndexError2(((NI)0),x_p0.len-1); goto BeforeRet_;		}		if ((x_p0.len) < ((NI)0) || (x_p0.len) > ((NI)IL64(9223372036854775807))){ raiseRangeErrorI(x_p0.len, ((NI)0), ((NI)IL64(9223372036854775807))); goto BeforeRet_;		}		copyMem__system_u1745(result.internal, ((void*) ((&x_p0.p->data[((NI)0)]))), ((NI) (x_p0.len)));
	}
	goto LA1_;
LA3_: ;
	{		tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* T6_;		T6_ = NIM_NIL;		T6_ = (tyObject_MyError__fVAoPZxkmyx7potpEdBUTw*) nimNewObj(sizeof(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw), NIM_ALIGNOF(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw));		(*T6_).Sup.Sup.Sup.m_type = (&NTIv2__fVAoPZxkmyx7potpEdBUTw_);		(*T6_).Sup.Sup.name = "MyError";		(*T6_).Sup.Sup.message = TM__SRd76hP9cMfCzdUO857UhQQ_5;		(*T6_).Sup.Sup.parent = ((Exception*) NIM_NIL);
#line 18
		raiseExceptionEx((Exception*)T6_, "MyError", "initMyObj", "/home/runner/work/Nim/Nim/temp.nim", 18);goto BeforeRet_;	}
LA1_: ;
	}BeforeRet_: ;
	popFrame();	return result;}
#line 6 "/home/runner/work/Nim/Nim/temp.nim"
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u5)(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw x_p0) {	nimfr_("=destroy", "/home/runner/work/Nim/Nim/temp.nim");{
#line 7
	{		if (!(x_p0.internal == 0)) goto LA3_;
		goto BeforeRet_;
	}
LA3_: ;
#line 8
	free(x_p0.internal);
	}BeforeRet_: ;
	popFrame();}
#line 237 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arc.nim"
static N_INLINE(NIM_BOOL, isObjDisplayCheck)(TNimTypeV2* source_p0, NI16 targetDepth_p1, NU32 token_p2) {	NIM_BOOL result;	NIM_BOOL T1_;	nimfr_("isObjDisplayCheck", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/arc.nim");	result = (NIM_BOOL)0;
#line 238
	T1_ = (NIM_BOOL)0;	T1_ = (targetDepth_p1 <= (*source_p0).depth);	if (!(T1_)) goto LA2_;
	T1_ = ((*source_p0).display[targetDepth_p1] == token_p2);LA2_: ;
	result = T1_;	popFrame();	return result;}
#line 2209 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim"
static N_INLINE(Exception*, nimBorrowCurrentException)(void) {	Exception* result;	nimfr_("nimBorrowCurrentException", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim");	result = NIM_NIL;
#line 2212
	result = currException__system_u3604;	popFrame();	return result;}
#line 2205 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim"
static N_INLINE(Exception*, getCurrentException)(void) {	Exception* result;	nimfr_("getCurrentException", "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim");	result = NIM_NIL;
#line 247 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/std/typedthreads.nim"
	eqcopy___stdZtypedthreads_u195(&result, currException__system_u3604);
	popFrame();	return result;}
#line 18 "/home/runner/work/Nim/Nim/temp.nim"
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___temp_u55)(tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* dest_p0) {	{		NIM_BOOL T3_;		T3_ = (NIM_BOOL)0;		T3_ = nimDecRefIsLast(dest_p0);		if (!T3_) goto LA4_;
		nimDestroyAndDispose(dest_p0);
	}
LA4_: ;
}
#line 137 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system/excpt.nim"
static N_INLINE(void, popCurrentException)(void) {
#line 247 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/std/typedthreads.nim"
	eqcopy___stdZtypedthreads_u195(&currException__system_u3604, (*currException__system_u3604).up);
}
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) {
#line 999999 "generated_not_to_break_here"
{
#line 21 "/home/runner/work/Nim/Nim/temp.nim"
tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw colontmpD_;	NimStringV2 colontmpD__2;	
#line 22
NimStringV2 colontmpD__3;	tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw colontmpD__4;	NimStringV2 colontmpD__5;	tyArray__nHXaesL0DJZHyVS07ARPRA T3_;	tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw T4_;	NimStringV2 T5_;	tyArray__nHXaesL0DJZHyVS07ARPRA T6_;	NimStringV2 T7_;	tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw T8_;	NimStringV2 T9_;NIM_BOOL oldNimErrFin2_;NIM_BOOL oldNimErrFin15_;NIM_BOOL* nimErr_;	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");nimErr_ = nimErrorFlag();	nimZeroMem((void*)(&colontmpD_), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));	colontmpD__2.len = 0; colontmpD__2.p = NIM_NIL;	colontmpD__3.len = 0; colontmpD__3.p = NIM_NIL;	nimZeroMem((void*)(&colontmpD__4), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));	colontmpD__5.len = 0; colontmpD__5.p = NIM_NIL;
#line 21
	nimZeroMem((void*)(&T4_), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));	T4_ = initMyObj__temp_u10(TM__SRd76hP9cMfCzdUO857UhQQ_7);	if (NIM_UNLIKELY(*nimErr_)) goto LA2_;	colontmpD_ = T4_;	T5_.len = 0; T5_.p = NIM_NIL;	T5_ = dollar___temp_u92(colontmpD_);	if (NIM_UNLIKELY(*nimErr_)) goto LA2_;	colontmpD__2 = T5_;	T3_[0] = colontmpD__2;	echoBinSafe(T3_, 1);
#line 22
	T7_.len = 0; T7_.p = NIM_NIL;	T7_ = nsuRepeatStr(TM__SRd76hP9cMfCzdUO857UhQQ_8, ((NI)128));	if (NIM_UNLIKELY(*nimErr_)) goto LA2_;	colontmpD__3 = T7_;	nimZeroMem((void*)(&T8_), sizeof(tyObject_MyObj__1rcrV49c4EzYn3tc8cj8MTw));	T8_ = initMyObj__temp_u10(colontmpD__3);	if (NIM_UNLIKELY(*nimErr_)) goto LA2_;	colontmpD__4 = T8_;	T9_.len = 0; T9_.p = NIM_NIL;	T9_ = dollar___temp_u92(colontmpD__4);	if (NIM_UNLIKELY(*nimErr_)) goto LA2_;	colontmpD__5 = T9_;	T6_[0] = colontmpD__5;	echoBinSafe(T6_, 1);	{		LA2_:;	}
	{		oldNimErrFin2_ = *nimErr_; *nimErr_ = NIM_FALSE;
#line 370 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim"
		if (colontmpD__5.p && !(colontmpD__5.p->cap & NIM_STRLIT_FLAG)) { deallocShared(colontmpD__5.p);}
#line 6 "/home/runner/work/Nim/Nim/temp.nim"
		eqdestroy___temp_u5(colontmpD__4);
		if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
#line 370 "/home/runner/.choosenim/toolchains/nim-2.0.0/lib/system.nim"
		if (colontmpD__3.p && !(colontmpD__3.p->cap & NIM_STRLIT_FLAG)) { deallocShared(colontmpD__3.p);}		if (colontmpD__2.p && !(colontmpD__2.p->cap & NIM_STRLIT_FLAG)) { deallocShared(colontmpD__2.p);}
#line 6 "/home/runner/work/Nim/Nim/temp.nim"
		eqdestroy___temp_u5(colontmpD_);
		if (NIM_UNLIKELY(*nimErr_)) goto LA1_;		*nimErr_ = oldNimErrFin2_;	}
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;	if (NIM_UNLIKELY(*nimErr_)) {		LA1_:;		if (isObjDisplayCheck(nimBorrowCurrentException()->Sup.m_type, 3, 1344814336)) {			
#line 23
tyObject_MyError__fVAoPZxkmyx7potpEdBUTw* e;			Exception* T16_;			tyArray__nHXaesL0DJZHyVS07ARPRA T17_;			*nimErr_ = NIM_FALSE;			e = NIM_NIL;
#line 24
			T16_ = NIM_NIL;			T16_ = getCurrentException();			e = ((tyObject_MyError__fVAoPZxkmyx7potpEdBUTw*) (T16_));
#line 24 "/home/runner/work/Nim/Nim/temp.nim"
			echoBinSafe(TM__SRd76hP9cMfCzdUO857UhQQ_9, 1);
#line 25
			T17_[0] = (*e).Sup.Sup.message;			echoBinSafe(T17_, 1);			{				LA15_:;			}
			{				oldNimErrFin15_ = *nimErr_; *nimErr_ = NIM_FALSE;
#line 18
				eqdestroy___temp_u55(e);
				if (NIM_UNLIKELY(*nimErr_)) goto LA13_;				*nimErr_ = oldNimErrFin15_;			}
			if (NIM_UNLIKELY(*nimErr_)) goto LA13_;			popCurrentException();			LA13_:;		}
	}
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;	BeforeRet_: ;
	nimTestErrorFlag();	popFrame();}
}

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("system"),
      newIdentNode("ansi_c")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("MyError"),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        nnkOfInherit.newTree(
          newIdentNode("CatchableError")
        ),
        newEmptyNode()
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("MyObj"),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("internal"),
            newIdentNode("pointer"),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    nnkAccQuoted.newTree(
      newIdentNode("="),
      newIdentNode("destroy")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("MyObj"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkIfStmt.newTree(
        nnkElifBranch.newTree(
          nnkDotExpr.newTree(
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("internal")
            ),
            newIdentNode("isNil")
          ),
          nnkStmtList.newTree(
            nnkReturnStmt.newTree(
              newEmptyNode()
            )
          )
        )
      ),
      nnkDotExpr.newTree(
        nnkDotExpr.newTree(
          newIdentNode("x"),
          newIdentNode("internal")
        ),
        newIdentNode("c_free")
      )
    )
  ),
  nnkProcDef.newTree(
    nnkAccQuoted.newTree(
      newIdentNode("="),
      newIdentNode("copy")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkVarTy.newTree(
          newIdentNode("MyObj")
        ),
        newEmptyNode()
      ),
      nnkIdentDefs.newTree(
        newIdentNode("y"),
        newIdentNode("MyObj"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkIfStmt.newTree(
        nnkElifBranch.newTree(
          nnkInfix.newTree(
            newIdentNode("!="),
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("internal")
            ),
            nnkDotExpr.newTree(
              newIdentNode("y"),
              newIdentNode("internal")
            )
          ),
          nnkStmtList.newTree(
            nnkDotExpr.newTree(
              nnkDotExpr.newTree(
                newIdentNode("x"),
                newIdentNode("internal")
              ),
              newIdentNode("c_free")
            ),
            nnkAsgn.newTree(
              nnkDotExpr.newTree(
                newIdentNode("x"),
                newIdentNode("internal")
              ),
              nnkDotExpr.newTree(
                newIdentNode("y"),
                newIdentNode("internal")
              )
            )
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("initMyObj"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("MyObj"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("string"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkAsgn.newTree(
        newIdentNode("result"),
        nnkObjConstr.newTree(
          newIdentNode("MyObj"),
          nnkExprColonExpr.newTree(
            newIdentNode("internal"),
            nnkCall.newTree(
              newIdentNode("c_malloc"),
              newLit(126)
            )
          )
        )
      ),
      nnkIfStmt.newTree(
        nnkElifBranch.newTree(
          nnkInfix.newTree(
            newIdentNode("<"),
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("len")
            ),
            newLit(128)
          ),
          nnkStmtList.newTree(
            nnkCall.newTree(
              nnkDotExpr.newTree(
                nnkDotExpr.newTree(
                  newIdentNode("result"),
                  newIdentNode("internal")
                ),
                newIdentNode("copyMem")
              ),
              nnkDotExpr.newTree(
                nnkBracketExpr.newTree(
                  newIdentNode("x"),
                  newLit(0)
                ),
                newIdentNode("addr")
              ),
              nnkDotExpr.newTree(
                newIdentNode("x"),
                newIdentNode("len")
              )
            )
          )
        ),
        nnkElse.newTree(
          nnkStmtList.newTree(
            nnkRaiseStmt.newTree(
              nnkCall.newTree(
                newIdentNode("newException"),
                newIdentNode("MyError"),
                newLit("This is an error")
              )
            )
          )
        )
      )
    )
  ),
  nnkImportStmt.newTree(
    newIdentNode("strutils")
  ),
  nnkTryStmt.newTree(
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        nnkCall.newTree(
          newIdentNode("initMyObj"),
          newLit("Hello world")
        )
      ),
      nnkCommand.newTree(
        newIdentNode("echo"),
        nnkCall.newTree(
          newIdentNode("initMyObj"),
          nnkCall.newTree(
            nnkDotExpr.newTree(
              newLit("Hello world"),
              newIdentNode("repeat")
            ),
            newLit(128)
          )
        )
      )
    ),
    nnkExceptBranch.newTree(
      nnkInfix.newTree(
        newIdentNode("as"),
        newIdentNode("MyError"),
        newIdentNode("e")
      ),
      nnkStmtList.newTree(
        nnkCommand.newTree(
          newIdentNode("echo"),
          newLit("Got an error!")
        ),
        nnkCommand.newTree(
          newIdentNode("echo"),
          nnkDotExpr.newTree(
            newIdentNode("e"),
            newIdentNode("msg")
          )
        )
      )
    )
  )
)
Stats
  • GCC 11.4.0
  • LibC 2.35
  • Valgrind 3.18.1
  • NodeJS 17.1
  • Linux 5.15.0
  • Created 2023-09-08T13:28:46Z
  • Comments 2
  • Commands nim c --gc:arc -d:useMalloc --expandArc:initMyObj -d:nimArcDebug -d:nimArcIds -d:nimAllocPagesViaMalloc -d:useSysAssert -d:useGcAssert -d:nimLeakDetector --debugger:native --debuginfo:on -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim && valgrind /home/runner/work/Nim/Nim/temp

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

@juancarlospaco
Copy link
Collaborator

@SirOlaf
Copy link
Contributor

SirOlaf commented Sep 9, 2023

No need for anything special, result just doesn't receive a call to destroy here. This will eat up memory pretty quick

proc leakMemory(): seq[char] =
  result = newSeq[char](128)
  raise newException(CatchableError, "This is an error")

while true:
  try:
    discard leakMemory()
  except CatchableError:
    echo GC_getStatistics()

This also leaks, so not exclusive to result (--exceptions:setjmp doesn't leak for this one, but I got no clue how to make use of that handler)

proc leakMemory(): seq[char] =
  var res = newSeq[char](128)
  try:
    raise newException(CatchableError, "This is an error")
  finally:
    return res

while true:
  try:
    discard leakMemory()
  except CatchableError:
    echo GC_getStatistics()

@ringabout
Copy link
Member

Another example: it leaks with ORC

import std/json

let startMemory = getOccupiedMem()
for i in 0 .. 10000:
  try:
    discard parseJson"""{ invalid"""
  except:
    discard
doAssert(abs(getOccupiedMem() - startMemory) < 4 * 1024 * 1024)

@PMunch
Copy link
Contributor Author

PMunch commented Apr 16, 2024

Just checked to see if this had been fixed in 2.0.4 and it is still present.

Araq added a commit that referenced this issue May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment