nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.59k stars 1.47k forks source link

C++ codegen failure for derived objects; C backend works correctly #16933

Open haxscramper opened 3 years ago

haxscramper commented 3 years ago

Compiling derived var object on C++ backend results in compilation error. No problems on C backend.

Example

type Base* = ref object of RootObj
method printSpace(c: var Base): void = discard

type Derived = ref object of Base
method printSpace(c: var Derived) = discard

Current Output

Compiling code snippet above procedes normally on C backend, but fails on C++ compilation stage with following error:

error: cannot declare pointer to ‘struct tyObject_DerivedcolonObjectType___FW7aSxX39cPPnHcJYWsg0YA*&’
  181 | sF9bArgw9ctJODfybwVmujw((*((tyObject_DerivedcolonObjectType___FW7aSxX39cPPnHcJYWsg0YA*&*) (&(c)))));

Expected Output

No compilation error for C++ backend

Possible Solution

Offending cast is generated in ccgtypes/getTypeDescAux().

https://github.com/nim-lang/Nim/blob/14c61ecf24110f3f6a1a4a9c88439e568065ddd9/compiler/ccgtypes.nim#L721

I couldn't figure out how to correctly fix this - simply removing cpp check obviously breaks a lot of other parts in compilation. If someone has any ideas on fixing this I will try looking into this myself.

Generated calls for C++ backend differ only in & used

c backend

printSpace__GsF9bArgw9ctJODfybwVmujw((*((
    tyObject_DerivedcolonObjectType___FW7aSxX39cPPnHcJYWsg0YA *
    /*{tfHasGCedMem, tfRefsAnonObj}tyRef*/* /*{tfHasGCedMem}tyVar*/*)(&(c)))));

cpp backend

printSpace__GsF9bArgw9ctJODfybwVmujw((*((
    tyObject_DerivedcolonObjectType___FW7aSxX39cPPnHcJYWsg0YA *
    /*{tfHasGCedMem, tfRefsAnonObj}tyRef*/& /*{tfHasGCedMem}tyVar*/*)(&(c)))));

Additional Information

I'g getting identical error when using cligen on CPP backend - I could not minimize it due to lots of macro-generated code, but

import cligen
proc trailCompile*(file: string) = discard
dispatchMulti([trailCompile])

also fails. I'm not entirely sure if this is related, but it gives the same error message under the same conditions (C++ dies, C ok)

$ nim -v
Nim Compiler Version 1.4.2 [Linux: amd64]
Compiled at 2020-11-30
Copyright (c) 2006-2020 by Andreas Rumpf

git hash: 3fb5157ab1b666a5a5c34efde0f357a82d433d04
active boot switches: -d:release -d:danger
ringabout commented 2 years ago

It seems to be a regression. Works in 1.2.x

ringabout commented 2 years ago

I didn't bother to run a git bisect, but I skimmed all commits between 1.4.0 and 1.2.0. Fortunately I find the culprit at the second guess => https://github.com/nim-lang/Nim/pull/14161

ringabout commented 1 year ago

@github-actions nim cpp

type Base* = ref object of RootObj
method printSpace(c: var Base): void = discard

type Derived = ref object of Base
method printSpace(c: var Derived) = discard
ringabout commented 1 year ago

@juancarlospaco Hi, do you happen to know why the CI wasn't finished?

juancarlospaco commented 1 year ago

@ringabout The bug is a codegen bug, is generating:

error: cannot declare pointer to ‘struct tyObject_DerivedcolonObjectType___QicCB7GN6dWokpZFgUI4JA*&’
  183 |                 printSpace__qGJls9cgdB4kneGWilyN1tg((*((tyObject_DerivedcolonObjectType___QicCB7GN6dWokpZFgUI4JA*&*) (&(c)))));
      |                                                                                                                   ^
Error: execution of an external compiler program 'g++ -c -std=gnu++14 -funsigned-char  -w -fmax-errors=3 -fpermissive   -I/home/runner/.choosenim/toolchains/nim-1.4.0/lib -I/home/runner/work/nimrun-action-minefield/nimrun-action-minefield -o /home/runner/work/nimrun-action-minefield/nimrun-action-minefield/@mtemp.nim.cpp.o /home/runner/work/nimrun-action-minefield/nimrun-action-minefield/@mtemp.nim.cpp' failed with exit code: 1

it is the line:

printSpace__qGJls9cgdB4kneGWilyN1tg((*((tyObject_DerivedcolonObjectType___QicCB7GN6dWokpZFgUI4JA*&*) (&(c)))));

and complaining on the *&*

The bot is failing because that sample is crashing all compilers from devel to 1.0 (older than 1.0 lang becomes too weird to bisect, strings and seqs are nil etc).

It needs at least 2 commits, 1 working, 1 non-working, then bisects between that range of commits until finds the breaking commit.

Basically that sample never worked properly in Nim.

That needs to be fixed/improved anyway, thanks for the info.

https://github.com/juancarlospaco/nimrun-action-minefield/actions/runs/5454609855/jobs/9924960902#step:4:166

juancarlospaco commented 1 year ago

@ringabout This commit introduced the bug: https://github.com/nim-lang/Nim/commit/d6e1b5c07#diff-4509107d295d7d32b1887c8993cd0f56113ae60f36113e7d8778646dabd92ebcR2475

ringabout commented 1 year ago

!nim cpp

type Base* = ref object of RootObj
method printSpace(c: var Base): void = discard

type Derived = ref object of Base
method printSpace(c: var Derived) = discard
github-actions[bot] commented 1 year ago

@ringabout (member)

devel :-1: FAIL

Output

Error: Command failed: nim cpp --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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
/home/runner/work/Nim/Nim/@mtemp.nim.cpp: In function ‘void printSpace__temp_u5(tyObject_BasecolonObjectType___SFAIOdEzctfKVNqIQKLDxg*&)’:
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:114:100: error: cannot declare pointer to ‘struct tyObject_DerivedcolonObjectType___AwqCt9aSFhIQcTn5A07aZPw*&’
  114 |                 printSpace__temp_u8((*((tyObject_DerivedcolonObjectType___AwqCt9aSFhIQcTn5A07aZPw*&*) (&(c_p0)))));
      |                                                                                                    ^
Error: execution of an external compiler program 'g++ -c -std=gnu++17 -funsigned-char  -w -fmax-errors=3 -fpermissive   -I'/home/runner/.choosenim/toolchains/nim-#devel/lib' -I/home/runner/work/Nim/Nim -o /home/runner/work/Nim/Nim/@mtemp.nim.cpp.o /home/runner/work/Nim/Nim/@mtemp.nim.cpp' failed with exit code: 1

Stats

  • Created 2023-07-05T00:31:37Z
  • Started 2023-07-05T00:32:13
  • Finished 2023-07-05T00:32:14
  • Duration 1 minute
  • Commands nim cpp --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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

IR

```cpp #define NIM_INTBITS 64 #include "nimbase.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; struct tyObject_BasecolonObjectType___SFAIOdEzctfKVNqIQKLDxg; struct tyObject_DerivedcolonObjectType___AwqCt9aSFhIQcTn5A07aZPw; struct RootObj; struct TNimTypeV2; struct TNimTypeV2 { void* destructor; NI size; NI16 align; NI16 depth; NU32* display; void* traceImpl; void* typeInfoV1; NI flags; }; struct RootObj { TNimTypeV2* m_type; }; struct tyObject_BasecolonObjectType___SFAIOdEzctfKVNqIQKLDxg : public RootObj { }; N_LIB_PRIVATE N_NIMCALL(void, printSpace__temp_u3)(tyObject_BasecolonObjectType___SFAIOdEzctfKVNqIQKLDxg*& c_p0); static N_INLINE(void, nimFrame)(TFrame* s_p0); N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4446)(void); static N_INLINE(void, popFrame)(void); N_LIB_PRIVATE N_NIMCALL(void, printSpace__temp_u8)(tyObject_DerivedcolonObjectType___AwqCt9aSFhIQcTn5A07aZPw*& c_p0); static N_INLINE(NIM_BOOL, isObjDisplayCheck)(TNimTypeV2* source_p0, NI16 targetDepth_p1, NU32 token_p2); N_LIB_PRIVATE N_NOINLINE(void, raiseObjectConversionError)(void); N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystematsexceptionsdotnim_DatInit000)(void); N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystemdotnim_Init000)(void); N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void); extern TFrame* framePtr__system_u3877; static N_INLINE(void, nimFrame)(TFrame* s_p0) { { if (!(framePtr__system_u3877 == ((TFrame*) NIM_NIL))) goto LA3_; { (*s_p0).calldepth = ((NI16)0); } } goto LA1_; LA3_: ; { (*s_p0).calldepth = (NI16)((*framePtr__system_u3877).calldepth + ((NI16)1)); } LA1_: ; (*s_p0).prev = framePtr__system_u3877; framePtr__system_u3877 = s_p0; { if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_; { callDepthLimitReached__system_u4446(); } } LA8_: ; } static N_INLINE(void, popFrame)(void) { framePtr__system_u3877 = (*framePtr__system_u3877).prev; } N_LIB_PRIVATE N_NIMCALL(void, printSpace__temp_u3)(tyObject_BasecolonObjectType___SFAIOdEzctfKVNqIQKLDxg*& c_p0) { nimfr_("printSpace", "/home/runner/work/Nim/Nim/temp.nim"); popFrame(); } N_LIB_PRIVATE N_NIMCALL(void, printSpace__temp_u8)(tyObject_DerivedcolonObjectType___AwqCt9aSFhIQcTn5A07aZPw*& c_p0) { nimfr_("printSpace", "/home/runner/work/Nim/Nim/temp.nim"); popFrame(); } 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-#devel/lib/system/arc.nim"); result = (NIM_BOOL)0; 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; } N_LIB_PRIVATE N_NIMCALL(void, printSpace__temp_u5)(tyObject_BasecolonObjectType___SFAIOdEzctfKVNqIQKLDxg*& c_p0) { nimfr_("printSpace", "/home/runner/work/Nim/Nim/temp.nim"); { if (!((c_p0) && (isObjDisplayCheck((*c_p0).m_type, 2, 176338688)))) goto LA3_; { if (c_p0 && !isObjDisplayCheck((*c_p0).m_type, 2, 176338688)){ raiseObjectConversionError(); } printSpace__temp_u8((*((tyObject_DerivedcolonObjectType___AwqCt9aSFhIQcTn5A07aZPw*&*) (&(c_p0))))); } } goto LA1_; LA3_: ; { if (!((c_p0) && (isObjDisplayCheck((*c_p0).m_type, 1, 1342716160)))) goto LA6_; { printSpace__temp_u3(c_p0); } } goto LA1_; LA6_: ; LA1_: ; popFrame(); } 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; atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystematsexceptionsdotnim_DatInit000(); atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystemdotnim_Init000(); (*inner)(); #else atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystematsexceptionsdotnim_DatInit000(); atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystemdotnim_Init000(); PreMainInner(); #endif } N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) { NimMainModule(); } N_CDECL(void, NimMain)(void) { #if 0 void (*volatile inner)(void); PreMain(); inner = NimMainInner; (*inner)(); #else PreMain(); NimMainInner(); #endif } int main(int argc, char** args, char** env) { cmdLine = args; cmdCount = argc; gEnv = env; NimMain(); return nim_program_result; } N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) { { } } ```

AST

```nim nnkStmtList.newTree( nnkTypeSection.newTree( nnkTypeDef.newTree( nnkPostfix.newTree( newIdentNode("*"), newIdentNode("Base") ), newEmptyNode(), nnkRefTy.newTree( nnkObjectTy.newTree( newEmptyNode(), nnkOfInherit.newTree( newIdentNode("RootObj") ), newEmptyNode() ) ) ) ), nnkMethodDef.newTree( newIdentNode("printSpace"), newEmptyNode(), newEmptyNode(), nnkFormalParams.newTree( newIdentNode("void"), nnkIdentDefs.newTree( newIdentNode("c"), nnkVarTy.newTree( newIdentNode("Base") ), newEmptyNode() ) ), newEmptyNode(), newEmptyNode(), nnkStmtList.newTree( nnkDiscardStmt.newTree( newEmptyNode() ) ) ), nnkTypeSection.newTree( nnkTypeDef.newTree( newIdentNode("Derived"), newEmptyNode(), nnkRefTy.newTree( nnkObjectTy.newTree( newEmptyNode(), nnkOfInherit.newTree( newIdentNode("Base") ), newEmptyNode() ) ) ) ), nnkMethodDef.newTree( newIdentNode("printSpace"), newEmptyNode(), newEmptyNode(), nnkFormalParams.newTree( newEmptyNode(), nnkIdentDefs.newTree( newIdentNode("c"), nnkVarTy.newTree( newIdentNode("Derived") ), newEmptyNode() ) ), newEmptyNode(), newEmptyNode(), nnkStmtList.newTree( nnkDiscardStmt.newTree( newEmptyNode() ) ) ) ) ```
stable :-1: FAIL

Output

Error: Command failed: nim cpp --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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
/home/runner/work/Nim/Nim/@mtemp.nim.cpp: In function ‘void printSpace__temp_5(tyObject_BasecolonObjectType___SFAIOdEzctfKVNqIQKLDxg*&)’:
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:162:99: error: cannot declare pointer to ‘struct tyObject_DerivedcolonObjectType___AwqCt9aSFhIQcTn5A07aZPw*&’
  162 |                 printSpace__temp_8((*((tyObject_DerivedcolonObjectType___AwqCt9aSFhIQcTn5A07aZPw*&*) (&(c)))));
      |                                                                                                   ^
Error: execution of an external compiler program 'g++ -c -std=gnu++14 -funsigned-char  -w -fmax-errors=3 -fpermissive   -I/home/runner/.choosenim/toolchains/nim-1.6.14/lib -I/home/runner/work/Nim/Nim -o /home/runner/work/Nim/Nim/@mtemp.nim.cpp.o /home/runner/work/Nim/Nim/@mtemp.nim.cpp' failed with exit code: 1

Stats

  • Created 2023-07-05T00:31:37Z
  • Started 2023-07-05T00:32:14
  • Finished 2023-07-05T00:32:15
  • Duration 1 minute
  • Commands nim cpp --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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

IR

```cpp #define NIM_INTBITS 64 #include "nimbase.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, file) \ FR_.line = n; FR_.filename = file; struct tyObject_BasecolonObjectType___SFAIOdEzctfKVNqIQKLDxg; struct tyObject_DerivedcolonObjectType___AwqCt9aSFhIQcTn5A07aZPw; struct RootObj; struct TNimType; struct TNimNode; typedef NU8 tyEnum_TNimKind__3rC59cFdCULJbp2tHLSZMXQ; typedef NU8 tySet_tyEnum_TNimTypeFlag__z9aX9aBGjlpDIC58y9bKcsmzA; typedef N_NIMCALL_PTR(void, tyProc__ojoeKfW4VYIm36I9cpDTQIg) (void* p, NI op); typedef N_NIMCALL_PTR(void*, tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ) (void* p); struct TNimType { NI size; NI align; tyEnum_TNimKind__3rC59cFdCULJbp2tHLSZMXQ kind; tySet_tyEnum_TNimTypeFlag__z9aX9aBGjlpDIC58y9bKcsmzA flags; TNimType* base; TNimNode* node; void* finalizer; tyProc__ojoeKfW4VYIm36I9cpDTQIg marker; tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ deepcopy; }; struct RootObj { TNimType* m_type; }; struct tyObject_BasecolonObjectType___SFAIOdEzctfKVNqIQKLDxg : public RootObj { }; typedef NU8 tyEnum_TNimNodeKind__XtzEyxd2A8uwMJcYYak9c7w; struct TNimNode { tyEnum_TNimNodeKind__XtzEyxd2A8uwMJcYYak9c7w kind; NI offset; TNimType* typ; NCSTRING name; NI len; TNimNode** sons; }; struct tyObject_DerivedcolonObjectType___AwqCt9aSFhIQcTn5A07aZPw : public tyObject_BasecolonObjectType___SFAIOdEzctfKVNqIQKLDxg { }; N_LIB_PRIVATE N_NIMCALL(void, printSpace__temp_3)(tyObject_BasecolonObjectType___SFAIOdEzctfKVNqIQKLDxg*& c); static N_INLINE(void, nimFrame)(TFrame* s); N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_2993)(void); static N_INLINE(void, popFrame)(void); N_LIB_PRIVATE N_NIMCALL(void, printSpace__temp_8)(tyObject_DerivedcolonObjectType___AwqCt9aSFhIQcTn5A07aZPw*& c); static N_INLINE(void, initStackBottomWith)(void* locals); N_LIB_PRIVATE N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom); N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, isObj)(TNimType* obj, TNimType* subclass); N_LIB_PRIVATE N_NOINLINE(void, raiseObjectConversionError)(void); static N_INLINE(NIM_BOOL, isObjWithCache)(TNimType* obj, TNimType* subclass, TNimType** cache); N_LIB_PRIVATE N_NOINLINE(NIM_BOOL, isObjSlowPath__system_3355)(TNimType* obj, TNimType* subclass, TNimType** cache); N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_DatInit000)(void); N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_Init000)(void); N_LIB_PRIVATE N_NIMCALL(void, atmtempdotnim_DatInit000)(void); N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void); extern TNimType NTIrootobj__ytyiCJqK439aF9cIibuRVpAg_; N_LIB_PRIVATE TNimType NTIbase58objecttype__SFAIOdEzctfKVNqIQKLDxg_; N_LIB_PRIVATE TNimType NTIderived58objecttype__AwqCt9aSFhIQcTn5A07aZPw_; extern TFrame* framePtr__system_2564; extern TFrame* framePtr__system_2564; extern TFrame* framePtr__system_2564; extern TFrame* framePtr__system_2564; extern TFrame* framePtr__system_2564; extern TFrame* framePtr__system_2564; static TNimType* Nim_OfCheck_CACHE3[2]; static N_INLINE(void, nimFrame)(TFrame* s) { { if (!(framePtr__system_2564 == ((TFrame*) NIM_NIL))) goto LA3_; { (*s).calldepth = ((NI16) 0); } } goto LA1_; LA3_: ; { (*s).calldepth = (NI16)((*framePtr__system_2564).calldepth + ((NI16) 1)); } LA1_: ; (*s).prev = framePtr__system_2564; framePtr__system_2564 = s; { if (!((*s).calldepth == ((NI16) 2000))) goto LA8_; { callDepthLimitReached__system_2993(); } } LA8_: ; } static N_INLINE(void, popFrame)(void) { framePtr__system_2564 = (*framePtr__system_2564).prev; } N_LIB_PRIVATE N_NIMCALL(void, printSpace__temp_3)(tyObject_BasecolonObjectType___SFAIOdEzctfKVNqIQKLDxg*& c) { nimfr_("printSpace", "/home/runner/work/Nim/Nim/temp.nim"); popFrame(); } N_LIB_PRIVATE N_NIMCALL(void, printSpace__temp_8)(tyObject_DerivedcolonObjectType___AwqCt9aSFhIQcTn5A07aZPw*& c) { nimfr_("printSpace", "/home/runner/work/Nim/Nim/temp.nim"); popFrame(); } static N_INLINE(void, initStackBottomWith)(void* locals) { nimGC_setStackBottom(locals); } static N_INLINE(NIM_BOOL, isObjWithCache)(TNimType* obj, TNimType* subclass, TNimType** cache) { NIM_BOOL result; { result = (NIM_BOOL)0; { if (!(obj == subclass)) goto LA3_; { result = NIM_TRUE; goto BeforeRet_; } } LA3_: ; { if (!((*obj).base == subclass)) goto LA7_; { result = NIM_TRUE; goto BeforeRet_; } } LA7_: ; { if (!(cache[(((NI) 0))- 0] == obj)) goto LA11_; { result = NIM_FALSE; goto BeforeRet_; } } LA11_: ; { if (!(cache[(((NI) 1))- 0] == obj)) goto LA15_; { result = NIM_TRUE; goto BeforeRet_; } } LA15_: ; result = isObjSlowPath__system_3355(obj, subclass, cache); goto BeforeRet_; }BeforeRet_: ; return result; } N_LIB_PRIVATE N_NIMCALL(void, printSpace__temp_5)(tyObject_BasecolonObjectType___SFAIOdEzctfKVNqIQKLDxg*& c) { nimfr_("printSpace", "/home/runner/work/Nim/Nim/temp.nim"); { if (!((c) && ((*c).m_type == (&NTIderived58objecttype__AwqCt9aSFhIQcTn5A07aZPw_)))) goto LA3_; { if (c && !isObj((*c).m_type, (&NTIderived58objecttype__AwqCt9aSFhIQcTn5A07aZPw_))){ raiseObjectConversionError(); } printSpace__temp_8((*((tyObject_DerivedcolonObjectType___AwqCt9aSFhIQcTn5A07aZPw*&*) (&(c))))); } } goto LA1_; LA3_: ; { if (!((c) && (isObjWithCache((*c).m_type, (&NTIbase58objecttype__SFAIOdEzctfKVNqIQKLDxg_), Nim_OfCheck_CACHE3)))) goto LA6_; { printSpace__temp_3(c); } } goto LA1_; LA6_: ; LA1_: ; popFrame(); } N_LIB_PRIVATE void PreMainInner(void) { } N_LIB_PRIVATE int cmdCount; N_LIB_PRIVATE char** cmdLine; N_LIB_PRIVATE char** gEnv; N_LIB_PRIVATE void PreMain(void) { void (*volatile inner)(void); inner = PreMainInner; atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_DatInit000(); initStackBottomWith((void *)&inner); atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_Init000(); atmtempdotnim_DatInit000(); (*inner)(); } N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) { NimMainModule(); } N_CDECL(void, NimMain)(void) { void (*volatile inner)(void); PreMain(); inner = NimMainInner; initStackBottomWith((void *)&inner); (*inner)(); } int main(int argc, char** args, char** env) { cmdLine = args; cmdCount = argc; gEnv = env; NimMain(); return nim_program_result; } N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) { { } } N_LIB_PRIVATE N_NIMCALL(void, atmtempdotnim_DatInit000)(void) { static TNimNode TM__SRd76hP9cMfCzdUO857UhQQ_0[2]; NTIbase58objecttype__SFAIOdEzctfKVNqIQKLDxg_.size = sizeof(tyObject_BasecolonObjectType___SFAIOdEzctfKVNqIQKLDxg); NTIbase58objecttype__SFAIOdEzctfKVNqIQKLDxg_.align = NIM_ALIGNOF(tyObject_BasecolonObjectType___SFAIOdEzctfKVNqIQKLDxg); NTIbase58objecttype__SFAIOdEzctfKVNqIQKLDxg_.kind = 17; NTIbase58objecttype__SFAIOdEzctfKVNqIQKLDxg_.base = (&NTIrootobj__ytyiCJqK439aF9cIibuRVpAg_); NTIbase58objecttype__SFAIOdEzctfKVNqIQKLDxg_.flags = 1; TM__SRd76hP9cMfCzdUO857UhQQ_0[0].len = 0; TM__SRd76hP9cMfCzdUO857UhQQ_0[0].kind = 2; NTIbase58objecttype__SFAIOdEzctfKVNqIQKLDxg_.node = &TM__SRd76hP9cMfCzdUO857UhQQ_0[0]; NTIderived58objecttype__AwqCt9aSFhIQcTn5A07aZPw_.size = sizeof(tyObject_DerivedcolonObjectType___AwqCt9aSFhIQcTn5A07aZPw); NTIderived58objecttype__AwqCt9aSFhIQcTn5A07aZPw_.align = NIM_ALIGNOF(tyObject_DerivedcolonObjectType___AwqCt9aSFhIQcTn5A07aZPw); NTIderived58objecttype__AwqCt9aSFhIQcTn5A07aZPw_.kind = 17; NTIderived58objecttype__AwqCt9aSFhIQcTn5A07aZPw_.base = (&NTIbase58objecttype__SFAIOdEzctfKVNqIQKLDxg_); NTIderived58objecttype__AwqCt9aSFhIQcTn5A07aZPw_.flags = 1; TM__SRd76hP9cMfCzdUO857UhQQ_0[1].len = 0; TM__SRd76hP9cMfCzdUO857UhQQ_0[1].kind = 2; NTIderived58objecttype__AwqCt9aSFhIQcTn5A07aZPw_.node = &TM__SRd76hP9cMfCzdUO857UhQQ_0[1]; } ```

AST

```nim nnkStmtList.newTree( nnkTypeSection.newTree( nnkTypeDef.newTree( nnkPostfix.newTree( newIdentNode("*"), newIdentNode("Base") ), newEmptyNode(), nnkRefTy.newTree( nnkObjectTy.newTree( newEmptyNode(), nnkOfInherit.newTree( newIdentNode("RootObj") ), newEmptyNode() ) ) ) ), nnkMethodDef.newTree( newIdentNode("printSpace"), newEmptyNode(), newEmptyNode(), nnkFormalParams.newTree( newIdentNode("void"), nnkIdentDefs.newTree( newIdentNode("c"), nnkVarTy.newTree( newIdentNode("Base") ), newEmptyNode() ) ), newEmptyNode(), newEmptyNode(), nnkStmtList.newTree( nnkDiscardStmt.newTree( newEmptyNode() ) ) ), nnkTypeSection.newTree( nnkTypeDef.newTree( newIdentNode("Derived"), newEmptyNode(), nnkRefTy.newTree( nnkObjectTy.newTree( newEmptyNode(), nnkOfInherit.newTree( newIdentNode("Base") ), newEmptyNode() ) ) ) ), nnkMethodDef.newTree( newIdentNode("printSpace"), newEmptyNode(), newEmptyNode(), nnkFormalParams.newTree( newEmptyNode(), nnkIdentDefs.newTree( newIdentNode("c"), nnkVarTy.newTree( newIdentNode("Derived") ), newEmptyNode() ) ), newEmptyNode(), newEmptyNode(), nnkStmtList.newTree( nnkDiscardStmt.newTree( newEmptyNode() ) ) ) ) ```
1.6.0 :-1: FAIL

Output

Error: Command failed: nim cpp --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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
/home/runner/work/Nim/Nim/@mtemp.nim.cpp: In function ‘void printSpace_temp_5(tyObject_BasecolonObjectType___9asAVjJCu2QuY51C9b6UdI2g*&)’:
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:162:99: error: cannot declare pointer to ‘struct tyObject_DerivedcolonObjectType___WrYyLJUEkyrGRYM9cG2P9cMw*&’
  162 |                 printSpace_temp_8((*((tyObject_DerivedcolonObjectType___WrYyLJUEkyrGRYM9cG2P9cMw*&*) (&(c)))));
      |                                                                                                   ^
Error: execution of an external compiler program 'g++ -c -std=gnu++14 -funsigned-char  -w -fmax-errors=3 -fpermissive   -I/home/runner/.choosenim/toolchains/nim-1.6.0/lib -I/home/runner/work/Nim/Nim -o /home/runner/work/Nim/Nim/@mtemp.nim.cpp.o /home/runner/work/Nim/Nim/@mtemp.nim.cpp' failed with exit code: 1

Stats

  • Created 2023-07-05T00:31:37Z
  • Started 2023-07-05T00:32:18
  • Finished 2023-07-05T00:32:18
  • Duration 1 minute
  • Commands nim cpp --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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

IR

```cpp #define NIM_INTBITS 64 #include "nimbase.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, file) \ FR_.line = n; FR_.filename = file; struct tyObject_BasecolonObjectType___9asAVjJCu2QuY51C9b6UdI2g; struct tyObject_DerivedcolonObjectType___WrYyLJUEkyrGRYM9cG2P9cMw; struct RootObj; struct TNimType; struct TNimNode; typedef NU8 tyEnum_TNimKind__jIBKr1ejBgsfM33Kxw4j7A; typedef NU8 tySet_tyEnum_TNimTypeFlag__v8QUszD1sWlSIWZz7mC4bQ; typedef N_NIMCALL_PTR(void, tyProc__ojoeKfW4VYIm36I9cpDTQIg) (void* p, NI op); typedef N_NIMCALL_PTR(void*, tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ) (void* p); struct TNimType { NI size; NI align; tyEnum_TNimKind__jIBKr1ejBgsfM33Kxw4j7A kind; tySet_tyEnum_TNimTypeFlag__v8QUszD1sWlSIWZz7mC4bQ flags; TNimType* base; TNimNode* node; void* finalizer; tyProc__ojoeKfW4VYIm36I9cpDTQIg marker; tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ deepcopy; }; struct RootObj { TNimType* m_type; }; struct tyObject_BasecolonObjectType___9asAVjJCu2QuY51C9b6UdI2g : public RootObj { }; typedef NU8 tyEnum_TNimNodeKind__unfNsxrcATrufDZmpBq4HQ; struct TNimNode { tyEnum_TNimNodeKind__unfNsxrcATrufDZmpBq4HQ kind; NI offset; TNimType* typ; NCSTRING name; NI len; TNimNode** sons; }; struct tyObject_DerivedcolonObjectType___WrYyLJUEkyrGRYM9cG2P9cMw : public tyObject_BasecolonObjectType___9asAVjJCu2QuY51C9b6UdI2g { }; N_LIB_PRIVATE N_NIMCALL(void, printSpace_temp_3)(tyObject_BasecolonObjectType___9asAVjJCu2QuY51C9b6UdI2g*& c); static N_INLINE(void, nimFrame)(TFrame* s); N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached_system_2993)(void); static N_INLINE(void, popFrame)(void); N_LIB_PRIVATE N_NIMCALL(void, printSpace_temp_8)(tyObject_DerivedcolonObjectType___WrYyLJUEkyrGRYM9cG2P9cMw*& c); static N_INLINE(void, initStackBottomWith)(void* locals); N_LIB_PRIVATE N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom); N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, isObj)(TNimType* obj, TNimType* subclass); N_LIB_PRIVATE N_NOINLINE(void, raiseObjectConversionError)(void); static N_INLINE(NIM_BOOL, isObjWithCache)(TNimType* obj, TNimType* subclass, TNimType** cache); N_LIB_PRIVATE N_NOINLINE(NIM_BOOL, isObjSlowPath_system_3347)(TNimType* obj, TNimType* subclass, TNimType** cache); N_LIB_PRIVATE N_NIMCALL(void, systemDatInit000)(void); N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void); N_LIB_PRIVATE N_NIMCALL(void, tempDatInit000)(void); N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void); extern TNimType NTIrootobj__ytyiCJqK439aF9cIibuRVpAg_; N_LIB_PRIVATE TNimType NTIbase58objecttype__9asAVjJCu2QuY51C9b6UdI2g_; N_LIB_PRIVATE TNimType NTIderived58objecttype__WrYyLJUEkyrGRYM9cG2P9cMw_; extern TFrame* framePtr_system_2564; extern TFrame* framePtr_system_2564; extern TFrame* framePtr_system_2564; extern TFrame* framePtr_system_2564; extern TFrame* framePtr_system_2564; extern TFrame* framePtr_system_2564; static TNimType* Nim_OfCheck_CACHE3[2]; static N_INLINE(void, nimFrame)(TFrame* s) { { if (!(framePtr_system_2564 == ((TFrame*) NIM_NIL))) goto LA3_; { (*s).calldepth = ((NI16) 0); } } goto LA1_; LA3_: ; { (*s).calldepth = (NI16)((*framePtr_system_2564).calldepth + ((NI16) 1)); } LA1_: ; (*s).prev = framePtr_system_2564; framePtr_system_2564 = s; { if (!((*s).calldepth == ((NI16) 2000))) goto LA8_; { callDepthLimitReached_system_2993(); } } LA8_: ; } static N_INLINE(void, popFrame)(void) { framePtr_system_2564 = (*framePtr_system_2564).prev; } N_LIB_PRIVATE N_NIMCALL(void, printSpace_temp_3)(tyObject_BasecolonObjectType___9asAVjJCu2QuY51C9b6UdI2g*& c) { nimfr_("printSpace", "/home/runner/work/Nim/Nim/temp.nim"); popFrame(); } N_LIB_PRIVATE N_NIMCALL(void, printSpace_temp_8)(tyObject_DerivedcolonObjectType___WrYyLJUEkyrGRYM9cG2P9cMw*& c) { nimfr_("printSpace", "/home/runner/work/Nim/Nim/temp.nim"); popFrame(); } static N_INLINE(void, initStackBottomWith)(void* locals) { nimGC_setStackBottom(locals); } static N_INLINE(NIM_BOOL, isObjWithCache)(TNimType* obj, TNimType* subclass, TNimType** cache) { NIM_BOOL result; { result = (NIM_BOOL)0; { if (!(obj == subclass)) goto LA3_; { result = NIM_TRUE; goto BeforeRet_; } } LA3_: ; { if (!((*obj).base == subclass)) goto LA7_; { result = NIM_TRUE; goto BeforeRet_; } } LA7_: ; { if (!(cache[(((NI) 0))- 0] == obj)) goto LA11_; { result = NIM_FALSE; goto BeforeRet_; } } LA11_: ; { if (!(cache[(((NI) 1))- 0] == obj)) goto LA15_; { result = NIM_TRUE; goto BeforeRet_; } } LA15_: ; result = isObjSlowPath_system_3347(obj, subclass, cache); goto BeforeRet_; }BeforeRet_: ; return result; } N_LIB_PRIVATE N_NIMCALL(void, printSpace_temp_5)(tyObject_BasecolonObjectType___9asAVjJCu2QuY51C9b6UdI2g*& c) { nimfr_("printSpace", "/home/runner/work/Nim/Nim/temp.nim"); { if (!((c) && ((*c).m_type == (&NTIderived58objecttype__WrYyLJUEkyrGRYM9cG2P9cMw_)))) goto LA3_; { if (c && !isObj((*c).m_type, (&NTIderived58objecttype__WrYyLJUEkyrGRYM9cG2P9cMw_))){ raiseObjectConversionError(); } printSpace_temp_8((*((tyObject_DerivedcolonObjectType___WrYyLJUEkyrGRYM9cG2P9cMw*&*) (&(c))))); } } goto LA1_; LA3_: ; { if (!((c) && (isObjWithCache((*c).m_type, (&NTIbase58objecttype__9asAVjJCu2QuY51C9b6UdI2g_), Nim_OfCheck_CACHE3)))) goto LA6_; { printSpace_temp_3(c); } } goto LA1_; LA6_: ; LA1_: ; popFrame(); } N_LIB_PRIVATE void PreMainInner(void) { } N_LIB_PRIVATE int cmdCount; N_LIB_PRIVATE char** cmdLine; N_LIB_PRIVATE char** gEnv; N_LIB_PRIVATE void PreMain(void) { void (*volatile inner)(void); inner = PreMainInner; systemDatInit000(); initStackBottomWith((void *)&inner); systemInit000(); tempDatInit000(); (*inner)(); } N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) { NimMainModule(); } N_CDECL(void, NimMain)(void) { void (*volatile inner)(void); PreMain(); inner = NimMainInner; initStackBottomWith((void *)&inner); (*inner)(); } int main(int argc, char** args, char** env) { cmdLine = args; cmdCount = argc; gEnv = env; NimMain(); return nim_program_result; } N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) { { } } N_LIB_PRIVATE N_NIMCALL(void, tempDatInit000)(void) { static TNimNode TM__SRd76hP9cMfCzdUO857UhQQ_0[2]; NTIbase58objecttype__9asAVjJCu2QuY51C9b6UdI2g_.size = sizeof(tyObject_BasecolonObjectType___9asAVjJCu2QuY51C9b6UdI2g); NTIbase58objecttype__9asAVjJCu2QuY51C9b6UdI2g_.align = NIM_ALIGNOF(tyObject_BasecolonObjectType___9asAVjJCu2QuY51C9b6UdI2g); NTIbase58objecttype__9asAVjJCu2QuY51C9b6UdI2g_.kind = 17; NTIbase58objecttype__9asAVjJCu2QuY51C9b6UdI2g_.base = (&NTIrootobj__ytyiCJqK439aF9cIibuRVpAg_); NTIbase58objecttype__9asAVjJCu2QuY51C9b6UdI2g_.flags = 1; TM__SRd76hP9cMfCzdUO857UhQQ_0[0].len = 0; TM__SRd76hP9cMfCzdUO857UhQQ_0[0].kind = 2; NTIbase58objecttype__9asAVjJCu2QuY51C9b6UdI2g_.node = &TM__SRd76hP9cMfCzdUO857UhQQ_0[0]; NTIderived58objecttype__WrYyLJUEkyrGRYM9cG2P9cMw_.size = sizeof(tyObject_DerivedcolonObjectType___WrYyLJUEkyrGRYM9cG2P9cMw); NTIderived58objecttype__WrYyLJUEkyrGRYM9cG2P9cMw_.align = NIM_ALIGNOF(tyObject_DerivedcolonObjectType___WrYyLJUEkyrGRYM9cG2P9cMw); NTIderived58objecttype__WrYyLJUEkyrGRYM9cG2P9cMw_.kind = 17; NTIderived58objecttype__WrYyLJUEkyrGRYM9cG2P9cMw_.base = (&NTIbase58objecttype__9asAVjJCu2QuY51C9b6UdI2g_); NTIderived58objecttype__WrYyLJUEkyrGRYM9cG2P9cMw_.flags = 1; TM__SRd76hP9cMfCzdUO857UhQQ_0[1].len = 0; TM__SRd76hP9cMfCzdUO857UhQQ_0[1].kind = 2; NTIderived58objecttype__WrYyLJUEkyrGRYM9cG2P9cMw_.node = &TM__SRd76hP9cMfCzdUO857UhQQ_0[1]; } ```

AST

```nim nnkStmtList.newTree( nnkTypeSection.newTree( nnkTypeDef.newTree( nnkPostfix.newTree( newIdentNode("*"), newIdentNode("Base") ), newEmptyNode(), nnkRefTy.newTree( nnkObjectTy.newTree( newEmptyNode(), nnkOfInherit.newTree( newIdentNode("RootObj") ), newEmptyNode() ) ) ) ), nnkMethodDef.newTree( newIdentNode("printSpace"), newEmptyNode(), newEmptyNode(), nnkFormalParams.newTree( newIdentNode("void"), nnkIdentDefs.newTree( newIdentNode("c"), nnkVarTy.newTree( newIdentNode("Base") ), newEmptyNode() ) ), newEmptyNode(), newEmptyNode(), nnkStmtList.newTree( nnkDiscardStmt.newTree( newEmptyNode() ) ) ), nnkTypeSection.newTree( nnkTypeDef.newTree( newIdentNode("Derived"), newEmptyNode(), nnkRefTy.newTree( nnkObjectTy.newTree( newEmptyNode(), nnkOfInherit.newTree( newIdentNode("Base") ), newEmptyNode() ) ) ) ), nnkMethodDef.newTree( newIdentNode("printSpace"), newEmptyNode(), newEmptyNode(), nnkFormalParams.newTree( newEmptyNode(), nnkIdentDefs.newTree( newIdentNode("c"), nnkVarTy.newTree( newIdentNode("Derived") ), newEmptyNode() ) ), newEmptyNode(), newEmptyNode(), nnkStmtList.newTree( nnkDiscardStmt.newTree( newEmptyNode() ) ) ) ) ```
1.4.0 :-1: FAIL

Output

Error: Command failed: nim cpp --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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
/home/runner/work/Nim/Nim/@mtemp.nim.cpp: In function ‘void printSpace__mkDNWpD0kIVP6f1gvo9cg4Q(tyObject_BasecolonObjectType___9asAVjJCu2QuY51C9b6UdI2g*&)’:
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:180:117: error: cannot declare pointer to ‘struct tyObject_DerivedcolonObjectType___WrYyLJUEkyrGRYM9cG2P9cMw*&’
  180 |                 printSpace__K9cIARQqQ3ijlHRnYAjBnKg((*((tyObject_DerivedcolonObjectType___WrYyLJUEkyrGRYM9cG2P9cMw*&*) (&(c)))));
      |                                                                                                                     ^
Error: execution of an external compiler program 'g++ -c -std=gnu++14 -funsigned-char  -w -fmax-errors=3 -fpermissive   -I/home/runner/.choosenim/toolchains/nim-1.4.0/lib -I/home/runner/work/Nim/Nim -o /home/runner/work/Nim/Nim/@mtemp.nim.cpp.o /home/runner/work/Nim/Nim/@mtemp.nim.cpp' failed with exit code: 1

Stats

  • Created 2023-07-05T00:31:37Z
  • Started 2023-07-05T00:32:21
  • Finished 2023-07-05T00:32:22
  • Duration 1 minute
  • Commands nim cpp --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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

IR

```cpp #define NIM_INTBITS 64 #include "nimbase.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, file) \ FR_.line = n; FR_.filename = file; struct tyObject_BasecolonObjectType___9asAVjJCu2QuY51C9b6UdI2g; struct tyObject_DerivedcolonObjectType___WrYyLJUEkyrGRYM9cG2P9cMw; struct RootObj; struct TNimType; struct TNimNode; typedef NU8 tyEnum_TNimKind__jIBKr1ejBgsfM33Kxw4j7A; typedef NU8 tySet_tyEnum_TNimTypeFlag__v8QUszD1sWlSIWZz7mC4bQ; typedef N_NIMCALL_PTR(void, tyProc__ojoeKfW4VYIm36I9cpDTQIg) (void* p, NI op); typedef N_NIMCALL_PTR(void*, tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ) (void* p); struct TNimType { NI size; NI align; tyEnum_TNimKind__jIBKr1ejBgsfM33Kxw4j7A kind; tySet_tyEnum_TNimTypeFlag__v8QUszD1sWlSIWZz7mC4bQ flags; TNimType* base; TNimNode* node; void* finalizer; tyProc__ojoeKfW4VYIm36I9cpDTQIg marker; tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ deepcopy; }; struct RootObj { TNimType* m_type; }; struct tyObject_BasecolonObjectType___9asAVjJCu2QuY51C9b6UdI2g : public RootObj { }; typedef NU8 tyEnum_TNimNodeKind__unfNsxrcATrufDZmpBq4HQ; struct TNimNode { tyEnum_TNimNodeKind__unfNsxrcATrufDZmpBq4HQ kind; NI offset; TNimType* typ; NCSTRING name; NI len; TNimNode** sons; }; struct tyObject_DerivedcolonObjectType___WrYyLJUEkyrGRYM9cG2P9cMw : public tyObject_BasecolonObjectType___9asAVjJCu2QuY51C9b6UdI2g { }; N_LIB_PRIVATE N_NIMCALL(void, printSpace__qsYHG9cCy09cJcoGo14gYnXg)(tyObject_BasecolonObjectType___9asAVjJCu2QuY51C9b6UdI2g*& c); static N_INLINE(void, nimFrame)(TFrame* s); N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__mMRdr4sgmnykA9aWeM9aDZlw)(void); static N_INLINE(void, popFrame)(void); N_LIB_PRIVATE N_NIMCALL(void, printSpace__K9cIARQqQ3ijlHRnYAjBnKg)(tyObject_DerivedcolonObjectType___WrYyLJUEkyrGRYM9cG2P9cMw*& c); static N_INLINE(void, initStackBottomWith)(void* locals); N_LIB_PRIVATE N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom); N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, isObj)(TNimType* obj, TNimType* subclass); N_LIB_PRIVATE N_NOINLINE(void, raiseObjectConversionError)(void); static N_INLINE(NIM_BOOL, isObjWithCache)(TNimType* obj, TNimType* subclass, TNimType** cache); N_LIB_PRIVATE N_NOINLINE(NIM_BOOL, isObjSlowPath__H8B7g6iFRPI5Em52KFoD6w)(TNimType* obj, TNimType* subclass, TNimType** cache); N_LIB_PRIVATE N_NIMCALL(void, systemDatInit000)(void); N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void); N_LIB_PRIVATE N_NIMCALL(void, tempDatInit000)(void); N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void); extern TNimType NTI__ytyiCJqK439aF9cIibuRVpAg_; N_LIB_PRIVATE TNimType NTI__9asAVjJCu2QuY51C9b6UdI2g_; N_LIB_PRIVATE TNimType NTI__WrYyLJUEkyrGRYM9cG2P9cMw_; extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; static TNimType* Nim_OfCheck_CACHE3[2]; static N_INLINE(void, nimFrame)(TFrame* s) { { if (!(framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw == NIM_NIL)) goto LA3_; { (*s).calldepth = ((NI16) 0); } } goto LA1_; LA3_: ; { (*s).calldepth = (NI16)((*framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw).calldepth + ((NI16) 1)); } LA1_: ; (*s).prev = framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw = s; { if (!((*s).calldepth == ((NI16) 2000))) goto LA8_; { callDepthLimitReached__mMRdr4sgmnykA9aWeM9aDZlw(); } } LA8_: ; } static N_INLINE(void, popFrame)(void) { framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw = (*framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw).prev; } N_LIB_PRIVATE N_NIMCALL(void, printSpace__qsYHG9cCy09cJcoGo14gYnXg)(tyObject_BasecolonObjectType___9asAVjJCu2QuY51C9b6UdI2g*& c) { nimfr_("printSpace", "/home/runner/work/Nim/Nim/temp.nim"); popFrame(); } N_LIB_PRIVATE N_NIMCALL(void, printSpace__K9cIARQqQ3ijlHRnYAjBnKg)(tyObject_DerivedcolonObjectType___WrYyLJUEkyrGRYM9cG2P9cMw*& c) { nimfr_("printSpace", "/home/runner/work/Nim/Nim/temp.nim"); popFrame(); } static N_INLINE(void, initStackBottomWith)(void* locals) { nimGC_setStackBottom(locals); } static N_INLINE(NIM_BOOL, isObjWithCache)(TNimType* obj, TNimType* subclass, TNimType** cache) { NIM_BOOL result; { result = (NIM_BOOL)0; { if (!(obj == subclass)) goto LA3_; { result = NIM_TRUE; goto BeforeRet_; } } LA3_: ; { if (!((*obj).base == subclass)) goto LA7_; { result = NIM_TRUE; goto BeforeRet_; } } LA7_: ; { if (!(cache[(((NI) 0))- 0] == obj)) goto LA11_; { result = NIM_FALSE; goto BeforeRet_; } } LA11_: ; { if (!(cache[(((NI) 1))- 0] == obj)) goto LA15_; { result = NIM_TRUE; goto BeforeRet_; } } LA15_: ; result = isObjSlowPath__H8B7g6iFRPI5Em52KFoD6w(obj, subclass, cache); goto BeforeRet_; }BeforeRet_: ; return result; } N_LIB_PRIVATE N_NIMCALL(void, printSpace__mkDNWpD0kIVP6f1gvo9cg4Q)(tyObject_BasecolonObjectType___9asAVjJCu2QuY51C9b6UdI2g*& c) { nimfr_("printSpace", "/home/runner/work/Nim/Nim/temp.nim"); { if (!((c) && ((*c).m_type == (&NTI__WrYyLJUEkyrGRYM9cG2P9cMw_)))) goto LA3_; { if (c && !isObj((*c).m_type, (&NTI__WrYyLJUEkyrGRYM9cG2P9cMw_))){ raiseObjectConversionError(); } printSpace__K9cIARQqQ3ijlHRnYAjBnKg((*((tyObject_DerivedcolonObjectType___WrYyLJUEkyrGRYM9cG2P9cMw*&*) (&(c))))); } } goto LA1_; LA3_: ; { if (!((c) && (isObjWithCache((*c).m_type, (&NTI__9asAVjJCu2QuY51C9b6UdI2g_), Nim_OfCheck_CACHE3)))) goto LA6_; { printSpace__qsYHG9cCy09cJcoGo14gYnXg(c); } } goto LA1_; LA6_: ; LA1_: ; popFrame(); } N_LIB_PRIVATE void PreMainInner(void) { } N_LIB_PRIVATE int cmdCount; N_LIB_PRIVATE char** cmdLine; N_LIB_PRIVATE char** gEnv; N_LIB_PRIVATE void PreMain(void) { void (*volatile inner)(void); inner = PreMainInner; systemDatInit000(); initStackBottomWith((void *)&inner); systemInit000(); tempDatInit000(); (*inner)(); } N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) { NimMainModule(); } N_CDECL(void, NimMain)(void) { void (*volatile inner)(void); PreMain(); inner = NimMainInner; initStackBottomWith((void *)&inner); (*inner)(); } int main(int argc, char** args, char** env) { cmdLine = args; cmdCount = argc; gEnv = env; NimMain(); return nim_program_result; } N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) { { } } N_LIB_PRIVATE N_NIMCALL(void, tempDatInit000)(void) { static TNimNode TM__SRd76hP9cMfCzdUO857UhQQ_0[2]; NTI__9asAVjJCu2QuY51C9b6UdI2g_.size = sizeof(tyObject_BasecolonObjectType___9asAVjJCu2QuY51C9b6UdI2g); NTI__9asAVjJCu2QuY51C9b6UdI2g_.align = NIM_ALIGNOF(tyObject_BasecolonObjectType___9asAVjJCu2QuY51C9b6UdI2g); NTI__9asAVjJCu2QuY51C9b6UdI2g_.kind = 17; NTI__9asAVjJCu2QuY51C9b6UdI2g_.base = (&NTI__ytyiCJqK439aF9cIibuRVpAg_); NTI__9asAVjJCu2QuY51C9b6UdI2g_.flags = 1; TM__SRd76hP9cMfCzdUO857UhQQ_0[0].len = 0; TM__SRd76hP9cMfCzdUO857UhQQ_0[0].kind = 2; NTI__9asAVjJCu2QuY51C9b6UdI2g_.node = &TM__SRd76hP9cMfCzdUO857UhQQ_0[0]; NTI__WrYyLJUEkyrGRYM9cG2P9cMw_.size = sizeof(tyObject_DerivedcolonObjectType___WrYyLJUEkyrGRYM9cG2P9cMw); NTI__WrYyLJUEkyrGRYM9cG2P9cMw_.align = NIM_ALIGNOF(tyObject_DerivedcolonObjectType___WrYyLJUEkyrGRYM9cG2P9cMw); NTI__WrYyLJUEkyrGRYM9cG2P9cMw_.kind = 17; NTI__WrYyLJUEkyrGRYM9cG2P9cMw_.base = (&NTI__9asAVjJCu2QuY51C9b6UdI2g_); NTI__WrYyLJUEkyrGRYM9cG2P9cMw_.flags = 1; TM__SRd76hP9cMfCzdUO857UhQQ_0[1].len = 0; TM__SRd76hP9cMfCzdUO857UhQQ_0[1].kind = 2; NTI__WrYyLJUEkyrGRYM9cG2P9cMw_.node = &TM__SRd76hP9cMfCzdUO857UhQQ_0[1]; } ```

AST

```nim nnkStmtList.newTree( nnkTypeSection.newTree( nnkTypeDef.newTree( nnkPostfix.newTree( newIdentNode("*"), newIdentNode("Base") ), newEmptyNode(), nnkRefTy.newTree( nnkObjectTy.newTree( newEmptyNode(), nnkOfInherit.newTree( newIdentNode("RootObj") ), newEmptyNode() ) ) ) ), nnkMethodDef.newTree( newIdentNode("printSpace"), newEmptyNode(), newEmptyNode(), nnkFormalParams.newTree( newIdentNode("void"), nnkIdentDefs.newTree( newIdentNode("c"), nnkVarTy.newTree( newIdentNode("Base") ), newEmptyNode() ) ), newEmptyNode(), newEmptyNode(), nnkStmtList.newTree( nnkDiscardStmt.newTree( newEmptyNode() ) ) ), nnkTypeSection.newTree( nnkTypeDef.newTree( newIdentNode("Derived"), newEmptyNode(), nnkRefTy.newTree( nnkObjectTy.newTree( newEmptyNode(), nnkOfInherit.newTree( newIdentNode("Base") ), newEmptyNode() ) ) ) ), nnkMethodDef.newTree( newIdentNode("printSpace"), newEmptyNode(), newEmptyNode(), nnkFormalParams.newTree( newEmptyNode(), nnkIdentDefs.newTree( newIdentNode("c"), nnkVarTy.newTree( newIdentNode("Derived") ), newEmptyNode() ) ), newEmptyNode(), newEmptyNode(), nnkStmtList.newTree( nnkDiscardStmt.newTree( newEmptyNode() ) ) ) ) ```
1.2.0 :+1: OK

Output

Stats

  • Created 2023-07-05T00:31:37Z
  • Started 2023-07-05T00:32:38
  • Finished 2023-07-05T00:32:38
  • Duration 1 minute
  • Commands nim cpp --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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
1.0.0 :+1: OK

Output

Stats

  • Created 2023-07-05T00:31:37Z
  • Started 2023-07-05T00:32:52
  • Finished 2023-07-05T00:32:52
  • Duration 1 minute
  • Commands nim cpp --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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
#d6e1b5c07 :arrow_right: :bug:

Diagnostics

Clyybber introduced a bug at 2020-04-30 02:01:07 +0200 on commit #d6e1b5c07 with message:

Fix #14160 (#14161)

* Fix #14160

* Add testcase

The bug is in the files:

compiler/ccgexprs.nim
tests/ccgbugs/t14160.nim

The bug can be in the commits:

(Diagnostics sometimes off-by-one).

:robot: Bug found in 22 minutes bisecting 4373 commits at 198 commits per second.

ringabout commented 1 year ago

@juancarlospaco Hello, would you mind introducing this super neat feature on the forum so that others can learn its existence?