-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Default valued generic proc parameter causes missing parameter in generated C code. #21258
Labels
Comments
!nim c type Item[T] = object
a: int
proc initItem[T](p=10000): Item[T] = Item[T](p)
proc doit[T](x:Item[T], s:Item[T]=initItem): string = $x.a
let x = Item[int](a:100)
discard doit(x) |
@juancarlospaco (contributor) devel :-1: FAILOutput
Stats
IR#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;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
typedef struct tyObject_Item__H419cwzytubuJJ8qvlHaLwA tyObject_Item__H419cwzytubuJJ8qvlHaLwA;
struct NimStrPayload {
NI cap;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
NI len;
NimStrPayload* p;
};
struct tyObject_Item__H419cwzytubuJJ8qvlHaLwA {
NI a;
};
N_LIB_PRIVATE N_NIMCALL(NimStringV2, doit__temp_u15)(tyObject_Item__H419cwzytubuJJ8qvlHaLwA x_p0, tyObject_Item__H419cwzytubuJJ8qvlHaLwA s_p1);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, dollar___systemZdollars_u8)(NI x_p0);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4483)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NOCONV(void, dealloc)(void* p_p0);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
N_LIB_PRIVATE NIM_CONST tyObject_Item__H419cwzytubuJJ8qvlHaLwA x__temp_u14 = {((NI)100)}
;
extern NIM_BOOL nimInErrorMode__system_u4265;
extern TFrame* framePtr__system_u3877;
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
NIM_BOOL* result;
result = (NIM_BOOL*)0;
result = (&nimInErrorMode__system_u4265);
return result;
}
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_u4483();
}
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
framePtr__system_u3877 = (*framePtr__system_u3877).prev;
}
N_LIB_PRIVATE N_NIMCALL(NimStringV2, doit__temp_u15)(tyObject_Item__H419cwzytubuJJ8qvlHaLwA x_p0, tyObject_Item__H419cwzytubuJJ8qvlHaLwA s_p1) {
NimStringV2 result;
NIM_BOOL* nimErr_;
nimfr_("doit", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
result.len = 0; result.p = NIM_NIL;
result = dollar___systemZdollars_u8(x_p0.a);
if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
}BeforeRet_: ;
popFrame();
return result;
}
N_LIB_PRIVATE void PreMainInner(void) {
}
N_LIB_PRIVATE int cmdCount;
N_LIB_PRIVATE char** cmdLine;
N_LIB_PRIVATE char** gEnv;
N_LIB_PRIVATE void PreMain(void) {
#if 0
void (*volatile inner)(void);
inner = PreMainInner;
atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystemdotnim_Init000();
(*inner)();
#else
atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystemdotnim_Init000();
PreMainInner();
#endif
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
NimMainModule();
}
N_CDECL(void, NimMain)(void) {
#if 0
void (*volatile inner)(void);
PreMain();
inner = NimMainInner;
(*inner)();
#else
PreMain();
NimMainInner();
#endif
}
int main(int argc, char** args, char** env) {
cmdLine = args;
cmdCount = argc;
gEnv = env;
NimMain();
return nim_program_result;
}
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) {
{
NimStringV2 colontmpD_;
NIM_BOOL* nimErr_;
nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
colontmpD_ = doit__temp_u15(x__temp_u14, );
if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
(void)(colontmpD_);
if (colontmpD_.p && !(colontmpD_.p->cap & NIM_STRLIT_FLAG)) {
dealloc(colontmpD_.p);
}
BeforeRet_: ;
nimTestErrorFlag();
popFrame();
}
} ASTnnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
newIdentNode("Item"),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
newIdentNode("a"),
newIdentNode("int"),
newEmptyNode()
)
)
)
)
),
nnkProcDef.newTree(
newIdentNode("initItem"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("T")
),
nnkIdentDefs.newTree(
newIdentNode("p"),
newEmptyNode(),
newLit(10000)
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkCall.newTree(
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("T")
),
newIdentNode("p")
)
)
),
nnkProcDef.newTree(
newIdentNode("doit"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
newIdentNode("string"),
nnkIdentDefs.newTree(
newIdentNode("x"),
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("T")
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("s"),
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("T")
),
newIdentNode("initItem")
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkPrefix.newTree(
newIdentNode("$"),
nnkDotExpr.newTree(
newIdentNode("x"),
newIdentNode("a")
)
)
)
),
nnkLetSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("x"),
newEmptyNode(),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("int")
),
nnkExprColonExpr.newTree(
newIdentNode("a"),
newLit(100)
)
)
)
),
nnkDiscardStmt.newTree(
nnkCall.newTree(
newIdentNode("doit"),
newIdentNode("x")
)
)
) stable :-1: FAILOutput
Stats
IR#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;
typedef struct tyObject_Item__H419cwzytubuJJ8qvlHaLwA tyObject_Item__H419cwzytubuJJ8qvlHaLwA;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
struct tyObject_Item__H419cwzytubuJJ8qvlHaLwA {
NI a;
};
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, doit__temp_15)(tyObject_Item__H419cwzytubuJJ8qvlHaLwA x, tyObject_Item__H419cwzytubuJJ8qvlHaLwA s);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, dollar___systemZdollars_3)(NI x);
static N_INLINE(void, nimFrame)(TFrame* s);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_2997)(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, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_DatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
N_LIB_PRIVATE NIM_CONST tyObject_Item__H419cwzytubuJJ8qvlHaLwA x__temp_14 = {((NI) 100)}
;
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 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_2997();
}
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
framePtr__system_2564 = (*framePtr__system_2564).prev;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, doit__temp_15)(tyObject_Item__H419cwzytubuJJ8qvlHaLwA x, tyObject_Item__H419cwzytubuJJ8qvlHaLwA s) {
NimStringDesc* result;
nimfr_("doit", "/home/runner/work/Nim/Nim/temp.nim");
result = NIM_NIL;
result = dollar___systemZdollars_3(x.a);
popFrame();
return result;
}
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;
atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_DatInit000();
initStackBottomWith((void *)&inner);
atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_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) {
{
NimStringDesc* T1_;
nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
T1_ = NIM_NIL;
T1_ = doit__temp_15(x__temp_14, );
(void)(T1_);
popFrame();
}
} ASTnnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
newIdentNode("Item"),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
newIdentNode("a"),
newIdentNode("int"),
newEmptyNode()
)
)
)
)
),
nnkProcDef.newTree(
newIdentNode("initItem"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("T")
),
nnkIdentDefs.newTree(
newIdentNode("p"),
newEmptyNode(),
newLit(10000)
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkCall.newTree(
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("T")
),
newIdentNode("p")
)
)
),
nnkProcDef.newTree(
newIdentNode("doit"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
newIdentNode("string"),
nnkIdentDefs.newTree(
newIdentNode("x"),
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("T")
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("s"),
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("T")
),
newIdentNode("initItem")
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkPrefix.newTree(
newIdentNode("$"),
nnkDotExpr.newTree(
newIdentNode("x"),
newIdentNode("a")
)
)
)
),
nnkLetSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("x"),
newEmptyNode(),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("int")
),
nnkExprColonExpr.newTree(
newIdentNode("a"),
newLit(100)
)
)
)
),
nnkDiscardStmt.newTree(
nnkCall.newTree(
newIdentNode("doit"),
newIdentNode("x")
)
)
) 1.6.0 :-1: FAILOutput
Stats
IR#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;
typedef struct tyObject_Item__zqgZX7PytdHwzAVQOKtg1A tyObject_Item__zqgZX7PytdHwzAVQOKtg1A;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
struct tyObject_Item__zqgZX7PytdHwzAVQOKtg1A {
NI a;
};
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, doit_temp_15)(tyObject_Item__zqgZX7PytdHwzAVQOKtg1A x, tyObject_Item__zqgZX7PytdHwzAVQOKtg1A s);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, dollar__systemZdollars_3)(NI x);
static N_INLINE(void, nimFrame)(TFrame* s);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached_system_2997)(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_Item__zqgZX7PytdHwzAVQOKtg1A x_temp_14 = {((NI) 100)}
;
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 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_2997();
}
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
framePtr_system_2564 = (*framePtr_system_2564).prev;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, doit_temp_15)(tyObject_Item__zqgZX7PytdHwzAVQOKtg1A x, tyObject_Item__zqgZX7PytdHwzAVQOKtg1A s) {
NimStringDesc* result;
nimfr_("doit", "/home/runner/work/Nim/Nim/temp.nim");
result = (NimStringDesc*)0;
result = dollar__systemZdollars_3(x.a);
popFrame();
return result;
}
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) {
{
NimStringDesc* T1_;
nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
T1_ = (NimStringDesc*)0;
T1_ = doit_temp_15(x_temp_14, );
(void)(T1_);
popFrame();
}
} ASTnnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
newIdentNode("Item"),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
newIdentNode("a"),
newIdentNode("int"),
newEmptyNode()
)
)
)
)
),
nnkProcDef.newTree(
newIdentNode("initItem"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("T")
),
nnkIdentDefs.newTree(
newIdentNode("p"),
newEmptyNode(),
newLit(10000)
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkCall.newTree(
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("T")
),
newIdentNode("p")
)
)
),
nnkProcDef.newTree(
newIdentNode("doit"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
newIdentNode("string"),
nnkIdentDefs.newTree(
newIdentNode("x"),
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("T")
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("s"),
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("T")
),
newIdentNode("initItem")
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkPrefix.newTree(
newIdentNode("$"),
nnkDotExpr.newTree(
newIdentNode("x"),
newIdentNode("a")
)
)
)
),
nnkLetSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("x"),
newEmptyNode(),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("int")
),
nnkExprColonExpr.newTree(
newIdentNode("a"),
newLit(100)
)
)
)
),
nnkDiscardStmt.newTree(
nnkCall.newTree(
newIdentNode("doit"),
newIdentNode("x")
)
)
) 1.4.0 :-1: FAILOutput
Stats
IR
#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;
typedef struct tyObject_Item__zqgZX7PytdHwzAVQOKtg1A tyObject_Item__zqgZX7PytdHwzAVQOKtg1A;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
struct tyObject_Item__zqgZX7PytdHwzAVQOKtg1A {
NI a;
};
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, doit__xXX5gi9babk9b2MG9am5AWFEA)(tyObject_Item__zqgZX7PytdHwzAVQOKtg1A x, tyObject_Item__zqgZX7PytdHwzAVQOKtg1A s);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nimIntToStr)(NI x);
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_Item__zqgZX7PytdHwzAVQOKtg1A x__FnxVSC5bS7DK6G1Il7xEdA = {((NI) 100)}
;
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, 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(NimStringDesc*, doit__xXX5gi9babk9b2MG9am5AWFEA)(tyObject_Item__zqgZX7PytdHwzAVQOKtg1A x, tyObject_Item__zqgZX7PytdHwzAVQOKtg1A s) {
NimStringDesc* result;
nimfr_("doit", "/home/runner/work/Nim/Nim/temp.nim");
result = (NimStringDesc*)0;
result = nimIntToStr(x.a);
popFrame();
return result;
}
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) {
{
NimStringDesc* T1_;
nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
T1_ = (NimStringDesc*)0;
T1_ = doit__xXX5gi9babk9b2MG9am5AWFEA(x__FnxVSC5bS7DK6G1Il7xEdA, );
(void)(T1_);
popFrame();
}
} ASTnnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
newIdentNode("Item"),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
newIdentNode("a"),
newIdentNode("int"),
newEmptyNode()
)
)
)
)
),
nnkProcDef.newTree(
newIdentNode("initItem"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("T")
),
nnkIdentDefs.newTree(
newIdentNode("p"),
newEmptyNode(),
newLit(10000)
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkCall.newTree(
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("T")
),
newIdentNode("p")
)
)
),
nnkProcDef.newTree(
newIdentNode("doit"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
newIdentNode("string"),
nnkIdentDefs.newTree(
newIdentNode("x"),
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("T")
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("s"),
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("T")
),
newIdentNode("initItem")
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkPrefix.newTree(
newIdentNode("$"),
nnkDotExpr.newTree(
newIdentNode("x"),
newIdentNode("a")
)
)
)
),
nnkLetSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("x"),
newEmptyNode(),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("int")
),
nnkExprColonExpr.newTree(
newIdentNode("a"),
newLit(100)
)
)
)
),
nnkDiscardStmt.newTree(
nnkCall.newTree(
newIdentNode("doit"),
newIdentNode("x")
)
)
) 1.2.0 :-1: FAILOutput
Stats
IR
#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;
typedef struct tyObject_Item__WOSegQZ0Dp7yGjGbb9bHzpA tyObject_Item__WOSegQZ0Dp7yGjGbb9bHzpA;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
struct tyObject_Item__WOSegQZ0Dp7yGjGbb9bHzpA {
NI a;
};
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, doit__hvQxJ9b2j09a0mG8br7PrGew)(tyObject_Item__WOSegQZ0Dp7yGjGbb9bHzpA x, tyObject_Item__WOSegQZ0Dp7yGjGbb9bHzpA s);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, nimIntToStr)(NI x);
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_Item__WOSegQZ0Dp7yGjGbb9bHzpA x__FnxVSC5bS7DK6G1Il7xEdA = {((NI) 100)}
;
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, 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(NimStringDesc*, doit__hvQxJ9b2j09a0mG8br7PrGew)(tyObject_Item__WOSegQZ0Dp7yGjGbb9bHzpA x, tyObject_Item__WOSegQZ0Dp7yGjGbb9bHzpA s) {
NimStringDesc* result;
nimfr_("doit", "/home/runner/work/Nim/Nim/temp.nim");
result = (NimStringDesc*)0;
result = nimIntToStr(x.a);
popFrame();
return result;
}
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) {
{
NimStringDesc* T1_;
nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
T1_ = (NimStringDesc*)0;
T1_ = doit__hvQxJ9b2j09a0mG8br7PrGew(x__FnxVSC5bS7DK6G1Il7xEdA, );
(void)(T1_);
popFrame();
}
} ASTnnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
newIdentNode("Item"),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
newIdentNode("a"),
newIdentNode("int"),
newEmptyNode()
)
)
)
)
),
nnkProcDef.newTree(
newIdentNode("initItem"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("T")
),
nnkIdentDefs.newTree(
newIdentNode("p"),
newEmptyNode(),
newLit(10000)
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkCall.newTree(
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("T")
),
newIdentNode("p")
)
)
),
nnkProcDef.newTree(
newIdentNode("doit"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
newIdentNode("string"),
nnkIdentDefs.newTree(
newIdentNode("x"),
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("T")
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("s"),
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("T")
),
newIdentNode("initItem")
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkPrefix.newTree(
newIdentNode("$"),
nnkDotExpr.newTree(
newIdentNode("x"),
newIdentNode("a")
)
)
)
),
nnkLetSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("x"),
newEmptyNode(),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("int")
),
nnkExprColonExpr.newTree(
newIdentNode("a"),
newLit(100)
)
)
)
),
nnkDiscardStmt.newTree(
nnkCall.newTree(
newIdentNode("doit"),
newIdentNode("x")
)
)
) 1.0.0 :-1: FAILOutput
Stats
IR
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.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;
typedef struct tyObject_Item__WOSegQZ0Dp7yGjGbb9bHzpA tyObject_Item__WOSegQZ0Dp7yGjGbb9bHzpA;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
struct tyObject_Item__WOSegQZ0Dp7yGjGbb9bHzpA {
NI a;
};
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
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(NimStringDesc*, doit__hvQxJ9b2j09a0mG8br7PrGew)(tyObject_Item__WOSegQZ0Dp7yGjGbb9bHzpA x, tyObject_Item__WOSegQZ0Dp7yGjGbb9bHzpA s);
N_NIMCALL(NimStringDesc*, nimIntToStr)(NI x);
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_Item__WOSegQZ0Dp7yGjGbb9bHzpA x__FnxVSC5bS7DK6G1Il7xEdA;
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(NimStringDesc*, doit__hvQxJ9b2j09a0mG8br7PrGew)(tyObject_Item__WOSegQZ0Dp7yGjGbb9bHzpA x, tyObject_Item__WOSegQZ0Dp7yGjGbb9bHzpA s) {
NimStringDesc* result;
nimfr_("doit", "/home/runner/work/Nim/Nim/temp.nim");
result = (NimStringDesc*)0;
result = nimIntToStr(x.a);
popFrame();
return result;
}
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) {
{
NimStringDesc* T1_;
nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
chckNil((void*)(&x__FnxVSC5bS7DK6G1Il7xEdA));
nimZeroMem((void*)(&x__FnxVSC5bS7DK6G1Il7xEdA), sizeof(tyObject_Item__WOSegQZ0Dp7yGjGbb9bHzpA));
x__FnxVSC5bS7DK6G1Il7xEdA.a = ((NI) 100);
T1_ = (NimStringDesc*)0;
T1_ = doit__hvQxJ9b2j09a0mG8br7PrGew(x__FnxVSC5bS7DK6G1Il7xEdA, );
(void)(T1_);
popFrame();
}
} ASTnnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
newIdentNode("Item"),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
newIdentNode("a"),
newIdentNode("int"),
newEmptyNode()
)
)
)
)
),
nnkProcDef.newTree(
newIdentNode("initItem"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("T")
),
nnkIdentDefs.newTree(
newIdentNode("p"),
newEmptyNode(),
newLit(10000)
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkCall.newTree(
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("T")
),
newIdentNode("p")
)
)
),
nnkProcDef.newTree(
newIdentNode("doit"),
newEmptyNode(),
nnkGenericParams.newTree(
nnkIdentDefs.newTree(
newIdentNode("T"),
newEmptyNode(),
newEmptyNode()
)
),
nnkFormalParams.newTree(
newIdentNode("string"),
nnkIdentDefs.newTree(
newIdentNode("x"),
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("T")
),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("s"),
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("T")
),
newIdentNode("initItem")
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkPrefix.newTree(
newIdentNode("$"),
nnkDotExpr.newTree(
newIdentNode("x"),
newIdentNode("a")
)
)
)
),
nnkLetSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("x"),
newEmptyNode(),
nnkObjConstr.newTree(
nnkBracketExpr.newTree(
newIdentNode("Item"),
newIdentNode("int")
),
nnkExprColonExpr.newTree(
newIdentNode("a"),
newLit(100)
)
)
)
),
nnkDiscardStmt.newTree(
nnkCall.newTree(
newIdentNode("doit"),
newIdentNode("x")
)
)
) 43 minutes bisecting 6 commits at 0 commits per second.
|
The problem is caused when the default value's type doesn't match the parameter's declared type which is the case here. proc foo*[T](x: seq[T], y: T = "foo") =
discard
foo @[1, 2, 3] |
The compiler notices this and sets an error node but the error node doesn't actually error. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
Code:
Nim Version
Nim Compiler Version 1.6.8 [Linux: amd64]
Compiled at 2022-10-05
Copyright (c) 2006-2021 by Andreas Rumpf
git hash: c9f46ca
active boot switches: -d:release
Current Output
Expected Output
I'd expect
proc doit[T](x:Item[T], s:HashSet[T]=initHashSet) : string =
to be either valid code or I should get a compile error.I do get an error, but it shows up as a gcc error, complaining about a missing parameter in a call.
This feels very opaque and doesn't show me what is wrong. My expectation would have been for the Nim compiler to error out, not for it to show up as a gcc error.
Possible Solution
Could Nim compiler error out instead of gcc crapping out on generated code?
Additional Information
This came up in a project where I defined
$
on a generic type, with a generic second parameter as HashSet[T]=initHashSet. In a unit test I got the error above. So it's not an academic question ;)The text was updated successfully, but these errors were encountered: