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.63k stars 1.47k forks source link

Wrapper types no longer resolve their fields in 2.0.10. #24415

Closed treeform closed 3 weeks ago

treeform commented 3 weeks ago

Description

This works on Nim 2.0.8 but breaks on 2.0.10:

type
  GVec2[T] = object
    x, y: T

type
  Uniform[T] = T

proc foo(v: Uniform[GVec2[float32]]) =
  echo v.x

let f = GVec2[float32](x: 1.0f, y: 2.0f)

foo(f)

Nim 2.0.8:

1.0

Nim 2.0.10:

uniform.nim(13, 4) Error: type mismatch
Expression: foo(f)
  [1] f: GVec2[system.float32]

Expected one of (first mismatch at [position]):
[1] proc foo(v: Uniform[GVec2[float32]])

Nim Version

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

git hash: e941ee15be775fe3c46db1bed9b4f41c7dfb1334 active boot switches: -d:relea

Current Output

No response

Expected Output

No response

Known Workarounds

No response

Additional Information

No response

treeform commented 3 weeks ago

Defining a converter:

converter uniformUnwrap[T](v: Uniform[T]): T = v

Does not help. This is not a distinct type should just work.

treeform commented 3 weeks ago

Looks like defining a converter that goes to and from works:

Nim Compiler Version 2.0.10 [Linux: amd64]:

type
  GVec2[T] = object
    x, y: T

type
  Uniform[T] = T

converter fromU[T](v: Uniform[T]): T = v
converter toU[T](v: T): Uniform[T] = v

proc foo(v: Uniform[GVec2[float32]]) =
  echo v.x

let f = GVec2[float32](x: 1.0f, y: 2.0f)

foo(f)
metagn commented 3 weeks ago

!nim c

type
  GVec2[T] = object
    x, y: T

type
  Uniform[T] = T

proc foo(v: Uniform[GVec2[float32]]) =
  echo v.x

let f = GVec2[float32](x: 1.0f, y: 2.0f)

foo(f)
github-actions[bot] commented 3 weeks ago
:penguin: Linux bisect by @metagn (collaborator)
devel :-1: FAIL

Output

``` ```

IR

Compiled filesize 0 (0 bytes) ```cpp ```

Stats

  • Started 2024-11-07T18:07:48
  • Finished 2024-11-07T18:07:49
  • Duration

AST

```nim nnkStmtList.newTree( nnkTypeSection.newTree( nnkTypeDef.newTree( newIdentNode("GVec2"), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newEmptyNode(), newEmptyNode() ) ), nnkObjectTy.newTree( newEmptyNode(), newEmptyNode(), nnkRecList.newTree( nnkIdentDefs.newTree( newIdentNode("x"), newIdentNode("y"), newIdentNode("T"), newEmptyNode() ) ) ) ) ), nnkTypeSection.newTree( nnkTypeDef.newTree( newIdentNode("Uniform"), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newEmptyNode(), newEmptyNode() ) ), newIdentNode("T") ) ), nnkProcDef.newTree( newIdentNode("foo"), newEmptyNode(), newEmptyNode(), nnkFormalParams.newTree( newEmptyNode(), nnkIdentDefs.newTree( newIdentNode("v"), nnkBracketExpr.newTree( newIdentNode("Uniform"), nnkBracketExpr.newTree( newIdentNode("GVec2"), newIdentNode("float32") ) ), newEmptyNode() ) ), newEmptyNode(), newEmptyNode(), nnkStmtList.newTree( nnkCommand.newTree( newIdentNode("echo"), nnkDotExpr.newTree( newIdentNode("v"), newIdentNode("x") ) ) ) ), nnkLetSection.newTree( nnkIdentDefs.newTree( newIdentNode("f"), newEmptyNode(), nnkObjConstr.newTree( nnkBracketExpr.newTree( newIdentNode("GVec2"), newIdentNode("float32") ), nnkExprColonExpr.newTree( newIdentNode("x"), newLit(1.0) ), nnkExprColonExpr.newTree( newIdentNode("y"), newLit(2.0) ) ) ) ), nnkCall.newTree( newIdentNode("foo"), newIdentNode("f") ) ) ```
stable :-1: FAIL

Output

``` ```

IR

Compiled filesize 0 (0 bytes) ```cpp ```

Stats

  • Started 2024-11-07T18:07:53
  • Finished 2024-11-07T18:07:53
  • Duration

AST

```nim nnkStmtList.newTree( nnkTypeSection.newTree( nnkTypeDef.newTree( newIdentNode("GVec2"), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newEmptyNode(), newEmptyNode() ) ), nnkObjectTy.newTree( newEmptyNode(), newEmptyNode(), nnkRecList.newTree( nnkIdentDefs.newTree( newIdentNode("x"), newIdentNode("y"), newIdentNode("T"), newEmptyNode() ) ) ) ) ), nnkTypeSection.newTree( nnkTypeDef.newTree( newIdentNode("Uniform"), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newEmptyNode(), newEmptyNode() ) ), newIdentNode("T") ) ), nnkProcDef.newTree( newIdentNode("foo"), newEmptyNode(), newEmptyNode(), nnkFormalParams.newTree( newEmptyNode(), nnkIdentDefs.newTree( newIdentNode("v"), nnkBracketExpr.newTree( newIdentNode("Uniform"), nnkBracketExpr.newTree( newIdentNode("GVec2"), newIdentNode("float32") ) ), newEmptyNode() ) ), newEmptyNode(), newEmptyNode(), nnkStmtList.newTree( nnkCommand.newTree( newIdentNode("echo"), nnkDotExpr.newTree( newIdentNode("v"), newIdentNode("x") ) ) ) ), nnkLetSection.newTree( nnkIdentDefs.newTree( newIdentNode("f"), newEmptyNode(), nnkObjConstr.newTree( nnkBracketExpr.newTree( newIdentNode("GVec2"), newIdentNode("float32") ), nnkExprColonExpr.newTree( newIdentNode("x"), newLit(1.0) ), nnkExprColonExpr.newTree( newIdentNode("y"), newLit(2.0) ) ) ) ), nnkCall.newTree( newIdentNode("foo"), newIdentNode("f") ) ) ```
2.0.10 :-1: FAIL

Output

``` ```

IR

Compiled filesize 0 (0 bytes) ```cpp ```

Stats

  • Started 2024-11-07T18:07:57
  • Finished 2024-11-07T18:07:57
  • Duration

AST

```nim nnkStmtList.newTree( nnkTypeSection.newTree( nnkTypeDef.newTree( newIdentNode("GVec2"), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newEmptyNode(), newEmptyNode() ) ), nnkObjectTy.newTree( newEmptyNode(), newEmptyNode(), nnkRecList.newTree( nnkIdentDefs.newTree( newIdentNode("x"), newIdentNode("y"), newIdentNode("T"), newEmptyNode() ) ) ) ) ), nnkTypeSection.newTree( nnkTypeDef.newTree( newIdentNode("Uniform"), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newEmptyNode(), newEmptyNode() ) ), newIdentNode("T") ) ), nnkProcDef.newTree( newIdentNode("foo"), newEmptyNode(), newEmptyNode(), nnkFormalParams.newTree( newEmptyNode(), nnkIdentDefs.newTree( newIdentNode("v"), nnkBracketExpr.newTree( newIdentNode("Uniform"), nnkBracketExpr.newTree( newIdentNode("GVec2"), newIdentNode("float32") ) ), newEmptyNode() ) ), newEmptyNode(), newEmptyNode(), nnkStmtList.newTree( nnkCommand.newTree( newIdentNode("echo"), nnkDotExpr.newTree( newIdentNode("v"), newIdentNode("x") ) ) ) ), nnkLetSection.newTree( nnkIdentDefs.newTree( newIdentNode("f"), newEmptyNode(), nnkObjConstr.newTree( nnkBracketExpr.newTree( newIdentNode("GVec2"), newIdentNode("float32") ), nnkExprColonExpr.newTree( newIdentNode("x"), newLit(1.0) ), nnkExprColonExpr.newTree( newIdentNode("y"), newLit(2.0) ) ) ) ), nnkCall.newTree( newIdentNode("foo"), newIdentNode("f") ) ) ```
2.0.0 :+1: OK

Output

``` ```

IR

Compiled filesize 91.52 Kb (93,712 bytes) ```cpp #include "nimbase.h" #define nimfr_(proc, file) \ TFrame FR_; \ FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_); #define nimfrs_(proc, file, slots, length) \ struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename;NI len;VarSlot s[slots];} FR_; \ FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_); #define nimln_(n) \ FR_.line = n; #define nimlf_(n, file) \ FR_.line = n; FR_.filename = file; typedef struct tyObject_GVec2__66rX5Mweh9bms7DbKC4I0jA tyObject_GVec2__66rX5Mweh9bms7DbKC4I0jA; typedef struct NimStrPayload NimStrPayload; typedef struct NimStringV2 NimStringV2; struct tyObject_GVec2__66rX5Mweh9bms7DbKC4I0jA { NF32 x; NF32 y; }; struct NimStrPayload { NI cap; NIM_CHAR data[SEQ_DECL_SIZE]; }; struct NimStringV2 { NI len; NimStrPayload* p; }; typedef NimStringV2 tyArray__nHXaesL0DJZHyVS07ARPRA[1]; N_LIB_PRIVATE N_NIMCALL(void, foo__temp_u7)(tyObject_GVec2__66rX5Mweh9bms7DbKC4I0jA v_p0); N_LIB_PRIVATE N_NIMCALL(NimStringV2, dollar___temp_u22)(NF32 x_p0); N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringV2* args_p0, NI args_p0Len_0); N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0); static N_INLINE(NIM_BOOL*, nimErrorFlag)(void); static N_INLINE(void, nimFrame)(TFrame* s_p0); N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4607)(void); static N_INLINE(void, popFrame)(void); N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void); N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000)(void); N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void); N_LIB_PRIVATE NIM_CONST tyObject_GVec2__66rX5Mweh9bms7DbKC4I0jA f__temp_u32 = {1.0f, 2.0f} ; extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4389; extern NIM_THREADVAR TFrame* framePtr__system_u4006; static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) { NIM_BOOL* result; result = (NIM_BOOL*)0; result = (&nimInErrorMode__system_u4389); return result; } static N_INLINE(void, nimFrame)(TFrame* s_p0) { { if (!(framePtr__system_u4006 == ((TFrame*) NIM_NIL))) goto LA3_; (*s_p0).calldepth = ((NI16)0); } goto LA1_; LA3_: ; { (*s_p0).calldepth = (NI16)((*framePtr__system_u4006).calldepth + ((NI16)1)); } LA1_: ; (*s_p0).prev = framePtr__system_u4006; framePtr__system_u4006 = s_p0; { if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_; callDepthLimitReached__system_u4607(); } LA8_: ; } static N_INLINE(void, popFrame)(void) { framePtr__system_u4006 = (*framePtr__system_u4006).prev; } N_LIB_PRIVATE N_NIMCALL(void, foo__temp_u7)(tyObject_GVec2__66rX5Mweh9bms7DbKC4I0jA v_p0) { NimStringV2 colontmpD_; tyArray__nHXaesL0DJZHyVS07ARPRA T2_; NIM_BOOL* nimErr_; nimfr_("foo", "/home/runner/work/Nim/Nim/temp.nim"); {nimErr_ = nimErrorFlag(); colontmpD_.len = 0; colontmpD_.p = NIM_NIL; colontmpD_ = dollar___temp_u22(v_p0.x); if (NIM_UNLIKELY(*nimErr_)) goto LA1_; T2_[0] = colontmpD_; echoBinSafe(T2_, 1); { LA1_:; } { if (colontmpD_.p && !(colontmpD_.p->cap & NIM_STRLIT_FLAG)) { deallocShared(colontmpD_.p); } } if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_; }BeforeRet_: ; 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; atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000(); (*inner)(); #else atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000(); PreMainInner(); #endif } N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) { NimMainModule(); } N_CDECL(void, NimMain)(void) { #if 0 void (*volatile inner)(void); PreMain(); inner = NimMainInner; (*inner)(); #else PreMain(); NimMainInner(); #endif } int main(int argc, char** args, char** env) { cmdLine = args; cmdCount = argc; gEnv = env; NimMain(); return nim_program_result; } N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) { { NIM_BOOL* nimErr_; nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim"); nimErr_ = nimErrorFlag(); foo__temp_u7(f__temp_u32); if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_; BeforeRet_: ; nimTestErrorFlag(); popFrame(); } } ```

Stats

  • Started 2024-11-07T18:08:01
  • Finished 2024-11-07T18:08:02
  • Duration
1.6.20 :+1: OK

Output

``` ```

IR

Compiled filesize 96.53 Kb (98,848 bytes) ```cpp #include "nimbase.h" #include # define nimfr_(proc, file) \ TFrame FR_; \ FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_); # define nimfrs_(proc, file, slots, length) \ struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename; NI len; VarSlot s[slots];} FR_; \ FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_); # define nimln_(n, file) \ FR_.line = n; FR_.filename = file; typedef struct tyObject_GVec2__66rX5Mweh9bms7DbKC4I0jA tyObject_GVec2__66rX5Mweh9bms7DbKC4I0jA; typedef struct NimStringDesc NimStringDesc; typedef struct TGenericSeq TGenericSeq; struct tyObject_GVec2__66rX5Mweh9bms7DbKC4I0jA { NF32 x; NF32 y; }; struct TGenericSeq { NI len; NI reserved; }; struct NimStringDesc { TGenericSeq Sup; NIM_CHAR data[SEQ_DECL_SIZE]; }; typedef NimStringDesc* tyArray__nHXaesL0DJZHyVS07ARPRA[1]; N_LIB_PRIVATE N_NIMCALL(void, foo__temp_u7)(tyObject_GVec2__66rX5Mweh9bms7DbKC4I0jA v); static N_INLINE(void, nimZeroMem)(void* p, NI size); static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a, int v, NI size); N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, dollar___system_u6860)(NF32 x); N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringDesc** args, NI argsLen_0); static N_INLINE(void, nimFrame)(TFrame* s); N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u2997)(void); static N_INLINE(void, popFrame)(void); static N_INLINE(void, initStackBottomWith)(void* locals); N_LIB_PRIVATE N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom); N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot20atslibatssystemdotnim_DatInit000)(void); N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot20atslibatssystemdotnim_Init000)(void); N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void); N_LIB_PRIVATE NIM_CONST tyObject_GVec2__66rX5Mweh9bms7DbKC4I0jA f__temp_u20 = {1.0f, 2.0f} ; extern TFrame* framePtr__system_u2564; static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a, int v, NI size) { void* T1_; T1_ = (void*)0; T1_ = memset(a, v, ((size_t) (size))); } static N_INLINE(void, nimZeroMem)(void* p, NI size) { nimSetMem__systemZmemory_u7(p, ((int) 0), size); } static N_INLINE(void, nimFrame)(TFrame* s) { { if (!(framePtr__system_u2564 == ((TFrame*) NIM_NIL))) goto LA3_; (*s).calldepth = ((NI16) 0); } goto LA1_; LA3_: ; { (*s).calldepth = (NI16)((*framePtr__system_u2564).calldepth + ((NI16) 1)); } LA1_: ; (*s).prev = framePtr__system_u2564; framePtr__system_u2564 = s; { if (!((*s).calldepth == ((NI16) 2000))) goto LA8_; callDepthLimitReached__system_u2997(); } LA8_: ; } static N_INLINE(void, popFrame)(void) { framePtr__system_u2564 = (*framePtr__system_u2564).prev; } N_LIB_PRIVATE N_NIMCALL(void, foo__temp_u7)(tyObject_GVec2__66rX5Mweh9bms7DbKC4I0jA v) { tyArray__nHXaesL0DJZHyVS07ARPRA T1_; nimfr_("foo", "/home/runner/work/Nim/Nim/temp.nim"); nimZeroMem((void*)T1_, sizeof(tyArray__nHXaesL0DJZHyVS07ARPRA)); T1_[0] = dollar___system_u6860(v.x); echoBinSafe(T1_, 1); popFrame(); } static N_INLINE(void, initStackBottomWith)(void* locals) { nimGC_setStackBottom(locals); } 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; atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot20atslibatssystemdotnim_DatInit000(); initStackBottomWith((void *)&inner); atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot20atslibatssystemdotnim_Init000(); (*inner)(); } N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) { NimMainModule(); } N_CDECL(void, NimMain)(void) { void (*volatile inner)(void); PreMain(); inner = NimMainInner; initStackBottomWith((void *)&inner); (*inner)(); } int main(int argc, char** args, char** env) { cmdLine = args; cmdCount = argc; gEnv = env; NimMain(); return nim_program_result; } N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) { { nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim"); foo__temp_u7(f__temp_u20); popFrame(); } } ```

Stats

  • Started 2024-11-07T18:08:05
  • Finished 2024-11-07T18:08:05
  • Duration
1.4.8 :+1: OK

Output

``` ```

IR

Compiled filesize 96.52 Kb (98,832 bytes) ```cpp #include "nimbase.h" #include # define nimfr_(proc, file) \ TFrame FR_; \ FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_); # define nimfrs_(proc, file, slots, length) \ struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename; NI len; VarSlot s[slots];} FR_; \ FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_); # define nimln_(n, file) \ FR_.line = n; FR_.filename = file; typedef struct tyObject_GVec2__9aV02qLixCqATxqgSZQRo7g tyObject_GVec2__9aV02qLixCqATxqgSZQRo7g; typedef struct NimStringDesc NimStringDesc; typedef struct TGenericSeq TGenericSeq; struct tyObject_GVec2__9aV02qLixCqATxqgSZQRo7g { NF32 x; NF32 y; }; struct TGenericSeq { NI len; NI reserved; }; struct NimStringDesc { TGenericSeq Sup; NIM_CHAR data[SEQ_DECL_SIZE]; }; typedef NimStringDesc* tyArray__nHXaesL0DJZHyVS07ARPRA[1]; N_LIB_PRIVATE N_NIMCALL(void, foo__FmNU3qksB145tWud2uhpng)(tyObject_GVec2__9aV02qLixCqATxqgSZQRo7g v); static N_INLINE(void, nimZeroMem)(void* p, NI size); static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size); N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nimFloatToStr)(NF f); N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringDesc** args, NI argsLen_0); static N_INLINE(void, nimFrame)(TFrame* s); N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__mMRdr4sgmnykA9aWeM9aDZlw)(void); static N_INLINE(void, popFrame)(void); static N_INLINE(void, initStackBottomWith)(void* locals); N_LIB_PRIVATE N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom); N_LIB_PRIVATE N_NIMCALL(void, systemDatInit000)(void); N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void); N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void); N_LIB_PRIVATE NIM_CONST tyObject_GVec2__9aV02qLixCqATxqgSZQRo7g f__XZ9a4tbpGvWZMz9b9aFtHXU0g = {1.0000000000000000e+00f, 2.0000000000000000e+00f} ; extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size) { void* T1_; T1_ = (void*)0; T1_ = memset(a, v, ((size_t) (size))); } static N_INLINE(void, nimZeroMem)(void* p, NI size) { nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory(p, ((int) 0), size); } static N_INLINE(void, nimFrame)(TFrame* s) { { if (!(framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw == ((TFrame*) NIM_NIL))) goto LA3_; (*s).calldepth = ((NI16) 0); } goto LA1_; LA3_: ; { (*s).calldepth = (NI16)((*framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw).calldepth + ((NI16) 1)); } LA1_: ; (*s).prev = framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw = s; { if (!((*s).calldepth == ((NI16) 2000))) goto LA8_; callDepthLimitReached__mMRdr4sgmnykA9aWeM9aDZlw(); } LA8_: ; } static N_INLINE(void, popFrame)(void) { framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw = (*framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw).prev; } N_LIB_PRIVATE N_NIMCALL(void, foo__FmNU3qksB145tWud2uhpng)(tyObject_GVec2__9aV02qLixCqATxqgSZQRo7g v) { tyArray__nHXaesL0DJZHyVS07ARPRA T1_; nimfr_("foo", "/home/runner/work/Nim/Nim/temp.nim"); nimZeroMem((void*)T1_, sizeof(tyArray__nHXaesL0DJZHyVS07ARPRA)); T1_[0] = nimFloatToStr(((NF) (v.x))); echoBinSafe(T1_, 1); popFrame(); } static N_INLINE(void, initStackBottomWith)(void* locals) { nimGC_setStackBottom(locals); } N_LIB_PRIVATE void PreMainInner(void) { } N_LIB_PRIVATE int cmdCount; N_LIB_PRIVATE char** cmdLine; N_LIB_PRIVATE char** gEnv; N_LIB_PRIVATE void PreMain(void) { void (*volatile inner)(void); inner = PreMainInner; systemDatInit000(); initStackBottomWith((void *)&inner); systemInit000(); (*inner)(); } N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) { NimMainModule(); } N_CDECL(void, NimMain)(void) { void (*volatile inner)(void); PreMain(); inner = NimMainInner; initStackBottomWith((void *)&inner); (*inner)(); } int main(int argc, char** args, char** env) { cmdLine = args; cmdCount = argc; gEnv = env; NimMain(); return nim_program_result; } N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) { { nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim"); foo__FmNU3qksB145tWud2uhpng(f__XZ9a4tbpGvWZMz9b9aFtHXU0g); popFrame(); } } ```

Stats

  • Started 2024-11-07T18:08:08
  • Finished 2024-11-07T18:08:09
  • Duration
1.2.18 :+1: OK

Output

``` ```

IR

Compiled filesize 92.24 Kb (94,456 bytes) ```cpp #include "nimbase.h" #include # define nimfr_(proc, file) \ TFrame FR_; \ FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_); # define nimfrs_(proc, file, slots, length) \ struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename; NI len; VarSlot s[slots];} FR_; \ FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_); # define nimln_(n, file) \ FR_.line = n; FR_.filename = file; typedef struct tyObject_GVec2__9aV02qLixCqATxqgSZQRo7g tyObject_GVec2__9aV02qLixCqATxqgSZQRo7g; typedef struct NimStringDesc NimStringDesc; typedef struct TGenericSeq TGenericSeq; struct tyObject_GVec2__9aV02qLixCqATxqgSZQRo7g { NF32 x; NF32 y; }; struct TGenericSeq { NI len; NI reserved; }; struct NimStringDesc { TGenericSeq Sup; NIM_CHAR data[SEQ_DECL_SIZE]; }; typedef NimStringDesc* tyArray__nHXaesL0DJZHyVS07ARPRA[1]; N_LIB_PRIVATE N_NIMCALL(void, foo__FmNU3qksB145tWud2uhpng)(tyObject_GVec2__9aV02qLixCqATxqgSZQRo7g v); static N_INLINE(void, nimZeroMem)(void* p, NI size); static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size); N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nimFloatToStr)(NF f); N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringDesc** args, NI argsLen_0); static N_INLINE(void, nimFrame)(TFrame* s); N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__mMRdr4sgmnykA9aWeM9aDZlw)(void); static N_INLINE(void, popFrame)(void); static N_INLINE(void, initStackBottomWith)(void* locals); N_LIB_PRIVATE N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom); N_LIB_PRIVATE N_NIMCALL(void, systemDatInit000)(void); N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void); N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void); N_LIB_PRIVATE NIM_CONST tyObject_GVec2__9aV02qLixCqATxqgSZQRo7g f__XZ9a4tbpGvWZMz9b9aFtHXU0g = {1.0000000000000000e+00f, 2.0000000000000000e+00f} ; extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size) { void* T1_; T1_ = (void*)0; T1_ = memset(a, v, ((size_t) (size))); } static N_INLINE(void, nimZeroMem)(void* p, NI size) { nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory(p, ((int) 0), size); } static N_INLINE(void, nimFrame)(TFrame* s) { { if (!(framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw == NIM_NIL)) goto LA3_; (*s).calldepth = ((NI16) 0); } goto LA1_; LA3_: ; { (*s).calldepth = (NI16)((*framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw).calldepth + ((NI16) 1)); } LA1_: ; (*s).prev = framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw = s; { if (!((*s).calldepth == ((NI16) (((NI) 2000))))) goto LA8_; callDepthLimitReached__mMRdr4sgmnykA9aWeM9aDZlw(); } LA8_: ; } static N_INLINE(void, popFrame)(void) { framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw = (*framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw).prev; } N_LIB_PRIVATE N_NIMCALL(void, foo__FmNU3qksB145tWud2uhpng)(tyObject_GVec2__9aV02qLixCqATxqgSZQRo7g v) { tyArray__nHXaesL0DJZHyVS07ARPRA T1_; nimfr_("foo", "/home/runner/work/Nim/Nim/temp.nim"); nimZeroMem((void*)T1_, sizeof(tyArray__nHXaesL0DJZHyVS07ARPRA)); T1_[0] = nimFloatToStr(((NF) (v.x))); echoBinSafe(T1_, 1); popFrame(); } static N_INLINE(void, initStackBottomWith)(void* locals) { nimGC_setStackBottom(locals); } N_LIB_PRIVATE void PreMainInner(void) { } N_LIB_PRIVATE int cmdCount; N_LIB_PRIVATE char** cmdLine; N_LIB_PRIVATE char** gEnv; N_LIB_PRIVATE void PreMain(void) { void (*volatile inner)(void); inner = PreMainInner; systemDatInit000(); initStackBottomWith((void *)&inner); systemInit000(); (*inner)(); } N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) { NimMainModule(); } N_CDECL(void, NimMain)(void) { void (*volatile inner)(void); PreMain(); inner = NimMainInner; initStackBottomWith((void *)&inner); (*inner)(); } int main(int argc, char** args, char** env) { cmdLine = args; cmdCount = argc; gEnv = env; NimMain(); return nim_program_result; } N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) { { nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim"); foo__FmNU3qksB145tWud2uhpng(f__XZ9a4tbpGvWZMz9b9aFtHXU0g); popFrame(); } } ```

Stats

  • Started 2024-11-07T18:08:11
  • Finished 2024-11-07T18:08:12
  • Duration
1.0.10 :+1: OK

Output

``` ```

IR

Compiled filesize 91.68 Kb (93,880 bytes) ```cpp #include "nimbase.h" #include # define nimfr_(proc, file) \ TFrame FR_; \ FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_); # define nimfrs_(proc, file, slots, length) \ struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename; NI len; VarSlot s[slots];} FR_; \ FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_); # define nimln_(n, file) \ FR_.line = n; FR_.filename = file; typedef struct tyObject_GVec2__9aV02qLixCqATxqgSZQRo7g tyObject_GVec2__9aV02qLixCqATxqgSZQRo7g; typedef struct NimStringDesc NimStringDesc; typedef struct TGenericSeq TGenericSeq; struct tyObject_GVec2__9aV02qLixCqATxqgSZQRo7g { NF32 x; NF32 y; }; struct TGenericSeq { NI len; NI reserved; }; struct NimStringDesc { TGenericSeq Sup; NIM_CHAR data[SEQ_DECL_SIZE]; }; typedef NimStringDesc* tyArray__nHXaesL0DJZHyVS07ARPRA[1]; N_NOINLINE(void, chckNil)(void* p); static N_INLINE(void, nimZeroMem)(void* p, NI size); static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size); N_LIB_PRIVATE N_NIMCALL(void, foo__FmNU3qksB145tWud2uhpng)(tyObject_GVec2__9aV02qLixCqATxqgSZQRo7g v); N_NIMCALL(NimStringDesc*, nimFloatToStr)(NF f); N_NIMCALL(void, echoBinSafe)(NimStringDesc** args, NI argsLen_0); static N_INLINE(void, nimFrame)(TFrame* s); N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__mMRdr4sgmnykA9aWeM9aDZlw)(void); static N_INLINE(void, popFrame)(void); static N_INLINE(void, initStackBottomWith)(void* locals); N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom); N_LIB_PRIVATE N_NIMCALL(void, systemDatInit000)(void); N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void); N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void); tyObject_GVec2__9aV02qLixCqATxqgSZQRo7g f__XZ9a4tbpGvWZMz9b9aFtHXU0g; extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size) { void* T1_; T1_ = (void*)0; T1_ = memset(a, v, ((size_t) (size))); } static N_INLINE(void, nimZeroMem)(void* p, NI size) { nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory(p, ((int) 0), size); } static N_INLINE(void, nimFrame)(TFrame* s) { NI T1_; T1_ = (NI)0; { if (!(framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw == NIM_NIL)) goto LA4_; T1_ = ((NI) 0); } goto LA2_; LA4_: ; { T1_ = ((NI) ((NI16)((*framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw).calldepth + ((NI16) 1)))); } LA2_: ; (*s).calldepth = ((NI16) (T1_)); (*s).prev = framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw = s; { if (!((*s).calldepth == ((NI16) (((NI) 2000))))) goto LA9_; callDepthLimitReached__mMRdr4sgmnykA9aWeM9aDZlw(); } LA9_: ; } static N_INLINE(void, popFrame)(void) { framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw = (*framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw).prev; } N_LIB_PRIVATE N_NIMCALL(void, foo__FmNU3qksB145tWud2uhpng)(tyObject_GVec2__9aV02qLixCqATxqgSZQRo7g v) { tyArray__nHXaesL0DJZHyVS07ARPRA T1_; nimfr_("foo", "/home/runner/work/Nim/Nim/temp.nim"); nimZeroMem((void*)T1_, sizeof(tyArray__nHXaesL0DJZHyVS07ARPRA)); T1_[0] = nimFloatToStr(((NF) (v.x))); echoBinSafe(T1_, 1); popFrame(); } static N_INLINE(void, initStackBottomWith)(void* locals) { nimGC_setStackBottom(locals); } void PreMainInner(void) { } int cmdCount; char** cmdLine; char** gEnv; void PreMain(void) { void (*volatile inner)(void); inner = PreMainInner; systemDatInit000(); initStackBottomWith((void *)&inner); systemInit000(); (*inner)(); } N_CDECL(void, NimMainInner)(void) { NimMainModule(); } N_CDECL(void, NimMain)(void) { void (*volatile inner)(void); PreMain(); inner = NimMainInner; initStackBottomWith((void *)&inner); (*inner)(); } int main(int argc, char** args, char** env) { cmdLine = args; cmdCount = argc; gEnv = env; NimMain(); return nim_program_result; } N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) { { nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim"); chckNil((void*)(&f__XZ9a4tbpGvWZMz9b9aFtHXU0g)); nimZeroMem((void*)(&f__XZ9a4tbpGvWZMz9b9aFtHXU0g), sizeof(tyObject_GVec2__9aV02qLixCqATxqgSZQRo7g)); f__XZ9a4tbpGvWZMz9b9aFtHXU0g.x = 1.0000000000000000e+00f; f__XZ9a4tbpGvWZMz9b9aFtHXU0g.y = 2.0000000000000000e+00f; foo__FmNU3qksB145tWud2uhpng(f__XZ9a4tbpGvWZMz9b9aFtHXU0g); popFrame(); } } ```

Stats

  • Started 2024-11-07T18:08:15
  • Finished 2024-11-07T18:08:15
  • Duration
??? :arrow_right: :bug:

Diagnostics

The commit that introduced the bug can not be found, but the bug is in the commits: (Can not find the commit because Nim can not be re-built commit-by-commit to bisect).
Stats
  • GCC 11.4.0
  • Clang 14.0.0
  • NodeJS 20.4
  • Created 2024-11-07T18:07:15Z
  • Comments 3
  • Commands nim c --run -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

:robot: Bug found in 9 mins bisecting 1039 commits at 109 commits per second

metagn commented 3 weeks ago

Of course it doesn't work

Culprit is #23978