Open LukeDeWaal opened 1 year ago
I've been hitting a similar issue in our nim-eth code base.
Minimized (does still use chronos) code snippit:
import chronos
type
Socket* = object
a*: int
ErrorType* = enum
ErrorA, ErrorB
Error* = object
case kind*: ErrorType
of ErrorA:
discard
of ErrorB:
discard
proc connect(s: Socket): Future[Error] {.async: (raises: [CancelledError]).} =
discard
let socket = Socket(a: 123)
let res = waitFor socket.connect()
Compiles fine with Nim 1.6.20:
Nim Compiler Version 1.6.20 [Linux: amd64]
Compiled at 2024-04-07
Copyright (c) 2006-2023 by Andreas Rumpf
git hash: 19fdbfc173bfccb64cb64e0a963e69f52f71fc73
active boot switches: -d:release
With Nim devel or 2.0.4
/home/deme/.cache/nim/extra_brace_d/@m..@s..@s.nimble@spkgs2@schronos-4.0.2-c736ec5b800fa8df7cf1be9da918578bd5e173d2@schronos@sinternal@sasyncfutures.nim.c:316:266: error: extra brace group at end of initializer
316 | tuidRCk31w_6 = {{{{{(&NTIv2__1go9brEQ7Per5SINHtx3UOw_)}, {NIM_NIL, NIM_NIL}, {0, NIM_NIL}, {NIM_NIL, NIM_NIL}, NIM_NIL, 0, 0, NIM_NIL, {NIM_NIL, NIM_NIL}}}, {0, {}}}, {}}
| ^
/home/deme/.cache/nim/extra_brace_d/@m..@s..@s.nimble@spkgs2@schronos-4.0.2-c736ec5b800fa8df7cf1be9da918578bd5e173d2@schronos@sinternal@sasyncfutures.nim.c:316:266: note: (near initialization for ‘TM__qMFlZYKlAiPttuidRCk31w_6.Sup.internalValue’)
Error: execution of an external compiler program 'gcc -c -w -fmax-errors=3 -pthread -I'/home/deme/.choosenim/toolchains/nim-#devel/lib' -I/home/deme/repos/nim-eth -o /home/deme/.cache/nim/extra_brace_d/@m..@s..@s.nimble@spkgs2@schronos-4.0.2-c736ec5b800fa8df7cf1be9da918578bd5e173d2@schronos@sinternal@sasyncfutures.nim.c.o /home/deme/.cache/nim/extra_brace_d/@m..@s..@s.nimble@spkgs2@schronos-4.0.2-c736ec5b800fa8df7cf1be9da918578bd5e173d2@schronos@sinternal@sasyncfutures.nim.c' failed with exit code: 1
Nim devel:
Nim Compiler Version 2.1.1 [Linux: amd64]
Compiled at 2024-06-10
Copyright (c) 2006-2024 by Andreas Rumpf
git hash: 56c95758b2777a36c8608a7b9950ba5ce8ce0b65
active boot switches: -d:release
Nim 2.0.4:
Nim Compiler Version 2.0.4 [Linux: amd64]
Compiled at 2024-03-28
Copyright (c) 2006-2023 by Andreas Rumpf
git hash: b47747d31844c6bd9af4322efe55e24fefea544c
active boot switches: -d:release
nim-chronos revision: 7630f394718ebcdb8577e36faacd78cb7a0b7dd6
Note that not using the object variant but instead directly the ErrorType
makes the compiling succeed.
!nim c
type
EmptySeq* {.bycopy.} = object
ChoiceWithEmptySeq_d* {.bycopy.} = object
a*: bool
INNER_C_UNION* {.bycopy, union.} = object
a*: char
b*: EmptySeq
c*: byte
d*: ChoiceWithEmptySeq_d
ChoiceWithEmptySeq_selection* = enum
ChoiceWithEmptySeq_NONE,
ChoiceWithEmptySeq_a_PRESENT,
ChoiceWithEmptySeq_b_PRESENT,
ChoiceWithEmptySeq_c_PRESENT,
ChoiceWithEmptySeq_d_PRESENT
ChoiceWithEmptySeq* {.bycopy.} = object
kind*: ChoiceWithEmptySeq_selection
u*: INNER_C_UNION
Og_Context* {.bycopy.} = object
state*: int
init_done*: bool
ch*: ChoiceWithEmptySeq
em*: EmptySeq
var context* : Og_Context = Og_Context(init_done: false)
0 (0 bytes)
```cpp
#define NIM_INTBITS 64
#include "nimbase.h"
typedef struct tyObject_Og_Context__1ZMSeuDcwNvPj6VrWwfiLg tyObject_Og_Context__1ZMSeuDcwNvPj6VrWwfiLg;
typedef struct tyObject_ChoiceWithEmptySeq__yAlpvnU3jHGuUtW7YazlKw tyObject_ChoiceWithEmptySeq__yAlpvnU3jHGuUtW7YazlKw;
typedef union tyObject_INNER_C_UNION__Ho3EQWBn9bl11Djiv0non1w tyObject_INNER_C_UNION__Ho3EQWBn9bl11Djiv0non1w;
typedef struct tyObject_EmptySeq__JEPYwSJUh7lAEOb4O7XoJw tyObject_EmptySeq__JEPYwSJUh7lAEOb4O7XoJw;
typedef struct tyObject_ChoiceWithEmptySeq_d__1rjgffnmmHGRUJ6ksfwyig tyObject_ChoiceWithEmptySeq_d__1rjgffnmmHGRUJ6ksfwyig;
typedef NU8 tyEnum_ChoiceWithEmptySeq_selection__y0C05wPaCBrO9acY9aRJcUTg;
struct tyObject_EmptySeq__JEPYwSJUh7lAEOb4O7XoJw {
char dummy;
};
struct tyObject_ChoiceWithEmptySeq_d__1rjgffnmmHGRUJ6ksfwyig {
NIM_BOOL a;
};
union tyObject_INNER_C_UNION__Ho3EQWBn9bl11Djiv0non1w {
NIM_CHAR a;
tyObject_EmptySeq__JEPYwSJUh7lAEOb4O7XoJw b;
NU8 c;
tyObject_ChoiceWithEmptySeq_d__1rjgffnmmHGRUJ6ksfwyig d;
};
struct tyObject_ChoiceWithEmptySeq__yAlpvnU3jHGuUtW7YazlKw {
tyEnum_ChoiceWithEmptySeq_selection__y0C05wPaCBrO9acY9aRJcUTg kind;
tyObject_INNER_C_UNION__Ho3EQWBn9bl11Djiv0non1w u;
};
struct tyObject_Og_Context__1ZMSeuDcwNvPj6VrWwfiLg {
NI state;
NIM_BOOL init_done;
tyObject_ChoiceWithEmptySeq__yAlpvnU3jHGuUtW7YazlKw ch;
tyObject_EmptySeq__JEPYwSJUh7lAEOb4O7XoJw em;
};
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 tyObject_Og_Context__1ZMSeuDcwNvPj6VrWwfiLg context__temp_u26 = {0, NIM_FALSE, {0, {0, {}, 0, {NIM_FALSE}}}, {}}
;
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) {
{
nimTestErrorFlag();
}
}
```
2024-06-11T10:27:30
2024-06-11T10:27:30
0 (0 bytes)
```cpp
#define NIM_INTBITS 64
#include "nimbase.h"
typedef struct tyObject_Og_Context__1ZMSeuDcwNvPj6VrWwfiLg tyObject_Og_Context__1ZMSeuDcwNvPj6VrWwfiLg;
typedef struct tyObject_ChoiceWithEmptySeq__yAlpvnU3jHGuUtW7YazlKw tyObject_ChoiceWithEmptySeq__yAlpvnU3jHGuUtW7YazlKw;
typedef union tyObject_INNER_C_UNION__Ho3EQWBn9bl11Djiv0non1w tyObject_INNER_C_UNION__Ho3EQWBn9bl11Djiv0non1w;
typedef struct tyObject_EmptySeq__JEPYwSJUh7lAEOb4O7XoJw tyObject_EmptySeq__JEPYwSJUh7lAEOb4O7XoJw;
typedef struct tyObject_ChoiceWithEmptySeq_d__1rjgffnmmHGRUJ6ksfwyig tyObject_ChoiceWithEmptySeq_d__1rjgffnmmHGRUJ6ksfwyig;
typedef NU8 tyEnum_ChoiceWithEmptySeq_selection__y0C05wPaCBrO9acY9aRJcUTg;
struct tyObject_EmptySeq__JEPYwSJUh7lAEOb4O7XoJw {
char dummy;
};
struct tyObject_ChoiceWithEmptySeq_d__1rjgffnmmHGRUJ6ksfwyig {
NIM_BOOL a;
};
union tyObject_INNER_C_UNION__Ho3EQWBn9bl11Djiv0non1w {
NIM_CHAR a;
tyObject_EmptySeq__JEPYwSJUh7lAEOb4O7XoJw b;
NU8 c;
tyObject_ChoiceWithEmptySeq_d__1rjgffnmmHGRUJ6ksfwyig d;
};
struct tyObject_ChoiceWithEmptySeq__yAlpvnU3jHGuUtW7YazlKw {
tyEnum_ChoiceWithEmptySeq_selection__y0C05wPaCBrO9acY9aRJcUTg kind;
tyObject_INNER_C_UNION__Ho3EQWBn9bl11Djiv0non1w u;
};
struct tyObject_Og_Context__1ZMSeuDcwNvPj6VrWwfiLg {
NI state;
NIM_BOOL init_done;
tyObject_ChoiceWithEmptySeq__yAlpvnU3jHGuUtW7YazlKw ch;
tyObject_EmptySeq__JEPYwSJUh7lAEOb4O7XoJw em;
};
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot4atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
N_LIB_PRIVATE tyObject_Og_Context__1ZMSeuDcwNvPj6VrWwfiLg context__temp_u26 = {0, NIM_FALSE, {0, {0, {}, 0, {NIM_FALSE}}}, {}}
;
N_LIB_PRIVATE void PreMainInner(void) {
}
N_LIB_PRIVATE int cmdCount;
N_LIB_PRIVATE char** cmdLine;
N_LIB_PRIVATE char** gEnv;
N_LIB_PRIVATE void PreMain(void) {
#if 0
void (*volatile inner)(void);
inner = PreMainInner;
atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot4atslibatssystemdotnim_Init000();
(*inner)();
#else
atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot4atslibatssystemdotnim_Init000();
PreMainInner();
#endif
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
NimMainModule();
}
N_CDECL(void, NimMain)(void) {
#if 0
void (*volatile inner)(void);
PreMain();
inner = NimMainInner;
(*inner)();
#else
PreMain();
NimMainInner();
#endif
}
int main(int argc, char** args, char** env) {
cmdLine = args;
cmdCount = argc;
gEnv = env;
NimMain();
return nim_program_result;
}
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) {
{
nimTestErrorFlag();
}
}
```
2024-06-11T10:27:31
2024-06-11T10:27:31
0 (0 bytes)
```cpp
#define NIM_INTBITS 64
#include "nimbase.h"
typedef struct tyObject_Og_Context__1ZMSeuDcwNvPj6VrWwfiLg tyObject_Og_Context__1ZMSeuDcwNvPj6VrWwfiLg;
typedef struct tyObject_ChoiceWithEmptySeq__yAlpvnU3jHGuUtW7YazlKw tyObject_ChoiceWithEmptySeq__yAlpvnU3jHGuUtW7YazlKw;
typedef union tyObject_INNER_C_UNION__Ho3EQWBn9bl11Djiv0non1w tyObject_INNER_C_UNION__Ho3EQWBn9bl11Djiv0non1w;
typedef struct tyObject_EmptySeq__JEPYwSJUh7lAEOb4O7XoJw tyObject_EmptySeq__JEPYwSJUh7lAEOb4O7XoJw;
typedef struct tyObject_ChoiceWithEmptySeq_d__1rjgffnmmHGRUJ6ksfwyig tyObject_ChoiceWithEmptySeq_d__1rjgffnmmHGRUJ6ksfwyig;
typedef NU8 tyEnum_ChoiceWithEmptySeq_selection__y0C05wPaCBrO9acY9aRJcUTg;
struct tyObject_EmptySeq__JEPYwSJUh7lAEOb4O7XoJw {
char dummy;
};
struct tyObject_ChoiceWithEmptySeq_d__1rjgffnmmHGRUJ6ksfwyig {
NIM_BOOL a;
};
union tyObject_INNER_C_UNION__Ho3EQWBn9bl11Djiv0non1w {
NIM_CHAR a;
tyObject_EmptySeq__JEPYwSJUh7lAEOb4O7XoJw b;
NU8 c;
tyObject_ChoiceWithEmptySeq_d__1rjgffnmmHGRUJ6ksfwyig d;
};
struct tyObject_ChoiceWithEmptySeq__yAlpvnU3jHGuUtW7YazlKw {
tyEnum_ChoiceWithEmptySeq_selection__y0C05wPaCBrO9acY9aRJcUTg kind;
tyObject_INNER_C_UNION__Ho3EQWBn9bl11Djiv0non1w u;
};
struct tyObject_Og_Context__1ZMSeuDcwNvPj6VrWwfiLg {
NI state;
NIM_BOOL init_done;
tyObject_ChoiceWithEmptySeq__yAlpvnU3jHGuUtW7YazlKw ch;
tyObject_EmptySeq__JEPYwSJUh7lAEOb4O7XoJw em;
};
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot4atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
N_LIB_PRIVATE tyObject_Og_Context__1ZMSeuDcwNvPj6VrWwfiLg context__temp_u26 = {0, NIM_FALSE, {0, {0, {}, 0, {NIM_FALSE}}}, {}}
;
N_LIB_PRIVATE void PreMainInner(void) {
}
N_LIB_PRIVATE int cmdCount;
N_LIB_PRIVATE char** cmdLine;
N_LIB_PRIVATE char** gEnv;
N_LIB_PRIVATE void PreMain(void) {
#if 0
void (*volatile inner)(void);
inner = PreMainInner;
atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot4atslibatssystemdotnim_Init000();
(*inner)();
#else
atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot4atslibatssystemdotnim_Init000();
PreMainInner();
#endif
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
NimMainModule();
}
N_CDECL(void, NimMain)(void) {
#if 0
void (*volatile inner)(void);
PreMain();
inner = NimMainInner;
(*inner)();
#else
PreMain();
NimMainInner();
#endif
}
int main(int argc, char** args, char** env) {
cmdLine = args;
cmdCount = argc;
gEnv = env;
NimMain();
return nim_program_result;
}
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) {
{
nimTestErrorFlag();
}
}
```
2024-06-11T10:27:32
2024-06-11T10:27:32
0 (0 bytes)
```cpp
#define NIM_INTBITS 64
#include "nimbase.h"
typedef struct tyObject_Og_Context__1ZMSeuDcwNvPj6VrWwfiLg tyObject_Og_Context__1ZMSeuDcwNvPj6VrWwfiLg;
typedef struct tyObject_ChoiceWithEmptySeq__yAlpvnU3jHGuUtW7YazlKw tyObject_ChoiceWithEmptySeq__yAlpvnU3jHGuUtW7YazlKw;
typedef union tyObject_INNER_C_UNION__Ho3EQWBn9bl11Djiv0non1w tyObject_INNER_C_UNION__Ho3EQWBn9bl11Djiv0non1w;
typedef struct tyObject_EmptySeq__JEPYwSJUh7lAEOb4O7XoJw tyObject_EmptySeq__JEPYwSJUh7lAEOb4O7XoJw;
typedef struct tyObject_ChoiceWithEmptySeq_d__1rjgffnmmHGRUJ6ksfwyig tyObject_ChoiceWithEmptySeq_d__1rjgffnmmHGRUJ6ksfwyig;
typedef NU8 tyEnum_ChoiceWithEmptySeq_selection__y0C05wPaCBrO9acY9aRJcUTg;
struct tyObject_EmptySeq__JEPYwSJUh7lAEOb4O7XoJw {
char dummy;
};
struct tyObject_ChoiceWithEmptySeq_d__1rjgffnmmHGRUJ6ksfwyig {
NIM_BOOL a;
};
union tyObject_INNER_C_UNION__Ho3EQWBn9bl11Djiv0non1w {
NIM_CHAR a;
tyObject_EmptySeq__JEPYwSJUh7lAEOb4O7XoJw b;
NU8 c;
tyObject_ChoiceWithEmptySeq_d__1rjgffnmmHGRUJ6ksfwyig d;
};
struct tyObject_ChoiceWithEmptySeq__yAlpvnU3jHGuUtW7YazlKw {
tyEnum_ChoiceWithEmptySeq_selection__y0C05wPaCBrO9acY9aRJcUTg kind;
tyObject_INNER_C_UNION__Ho3EQWBn9bl11Djiv0non1w u;
};
struct tyObject_Og_Context__1ZMSeuDcwNvPj6VrWwfiLg {
NI state;
NIM_BOOL init_done;
tyObject_ChoiceWithEmptySeq__yAlpvnU3jHGuUtW7YazlKw ch;
tyObject_EmptySeq__JEPYwSJUh7lAEOb4O7XoJw em;
};
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 tyObject_Og_Context__1ZMSeuDcwNvPj6VrWwfiLg context__temp_u26 = {0, NIM_FALSE, {0, {0, {}, 0, {NIM_FALSE}}}, {}}
;
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) {
{
nimTestErrorFlag();
}
}
```
2024-06-11T10:27:36
2024-06-11T10:27:36
0 (0 bytes)
```cpp
#define NIM_INTBITS 64
#include "nimbase.h"
#define nimfr_(x, y)
#define nimln_(x, y)
typedef struct tyObject_Og_Context__1ZMSeuDcwNvPj6VrWwfiLg tyObject_Og_Context__1ZMSeuDcwNvPj6VrWwfiLg;
typedef struct tyObject_ChoiceWithEmptySeq__yAlpvnU3jHGuUtW7YazlKw tyObject_ChoiceWithEmptySeq__yAlpvnU3jHGuUtW7YazlKw;
typedef union tyObject_INNER_C_UNION__Ho3EQWBn9bl11Djiv0non1w tyObject_INNER_C_UNION__Ho3EQWBn9bl11Djiv0non1w;
typedef struct tyObject_EmptySeq__JEPYwSJUh7lAEOb4O7XoJw tyObject_EmptySeq__JEPYwSJUh7lAEOb4O7XoJw;
typedef struct tyObject_ChoiceWithEmptySeq_d__1rjgffnmmHGRUJ6ksfwyig tyObject_ChoiceWithEmptySeq_d__1rjgffnmmHGRUJ6ksfwyig;
typedef NU8 tyEnum_ChoiceWithEmptySeq_selection__y0C05wPaCBrO9acY9aRJcUTg;
struct tyObject_EmptySeq__JEPYwSJUh7lAEOb4O7XoJw {
char dummy;
};
struct tyObject_ChoiceWithEmptySeq_d__1rjgffnmmHGRUJ6ksfwyig {
NIM_BOOL a;
};
union tyObject_INNER_C_UNION__Ho3EQWBn9bl11Djiv0non1w {
NIM_CHAR a;
tyObject_EmptySeq__JEPYwSJUh7lAEOb4O7XoJw b;
NU8 c;
tyObject_ChoiceWithEmptySeq_d__1rjgffnmmHGRUJ6ksfwyig d;
};
struct tyObject_ChoiceWithEmptySeq__yAlpvnU3jHGuUtW7YazlKw {
tyEnum_ChoiceWithEmptySeq_selection__y0C05wPaCBrO9acY9aRJcUTg kind;
tyObject_INNER_C_UNION__Ho3EQWBn9bl11Djiv0non1w u;
};
struct tyObject_Og_Context__1ZMSeuDcwNvPj6VrWwfiLg {
NI state;
NIM_BOOL init_done;
tyObject_ChoiceWithEmptySeq__yAlpvnU3jHGuUtW7YazlKw ch;
tyObject_EmptySeq__JEPYwSJUh7lAEOb4O7XoJw em;
};
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 tyObject_Og_Context__1ZMSeuDcwNvPj6VrWwfiLg context__temp_u26 = {0, NIM_FALSE, {0, {0, {}, 0, {NIM_FALSE}}}, {}}
;
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) {
{
}
}
```
2024-06-11T10:27:39
2024-06-11T10:27:40
0 (0 bytes)
```cpp
#define NIM_INTBITS 64
#include "nimbase.h"
#define nimfr_(x, y)
#define nimln_(x, y)
typedef struct tyObject_Og_Context__bxoIigb1FBm2Vw5v9ceQLew tyObject_Og_Context__bxoIigb1FBm2Vw5v9ceQLew;
typedef struct tyObject_ChoiceWithEmptySeq__t7AEMm29aSJZlarP2nlNXPg tyObject_ChoiceWithEmptySeq__t7AEMm29aSJZlarP2nlNXPg;
typedef union tyObject_INNER_C_UNION__nSy3jrICR0lkSmOVKZWCMw tyObject_INNER_C_UNION__nSy3jrICR0lkSmOVKZWCMw;
typedef struct tyObject_EmptySeq__uQOC49aSxZzQKcPkzjyqKvw tyObject_EmptySeq__uQOC49aSxZzQKcPkzjyqKvw;
typedef struct tyObject_ChoiceWithEmptySeq_d__hy9agYq3kWtyifGrTP355nw tyObject_ChoiceWithEmptySeq_d__hy9agYq3kWtyifGrTP355nw;
typedef NU8 tyEnum_ChoiceWithEmptySeq_selection__gM43DRIqTgBba2IBkbSf2Q;
struct tyObject_EmptySeq__uQOC49aSxZzQKcPkzjyqKvw {
char dummy;
};
struct tyObject_ChoiceWithEmptySeq_d__hy9agYq3kWtyifGrTP355nw {
NIM_BOOL a;
};
union tyObject_INNER_C_UNION__nSy3jrICR0lkSmOVKZWCMw {
NIM_CHAR a;
tyObject_EmptySeq__uQOC49aSxZzQKcPkzjyqKvw b;
NU8 c;
tyObject_ChoiceWithEmptySeq_d__hy9agYq3kWtyifGrTP355nw d;
};
struct tyObject_ChoiceWithEmptySeq__t7AEMm29aSJZlarP2nlNXPg {
tyEnum_ChoiceWithEmptySeq_selection__gM43DRIqTgBba2IBkbSf2Q kind;
tyObject_INNER_C_UNION__nSy3jrICR0lkSmOVKZWCMw u;
};
struct tyObject_Og_Context__bxoIigb1FBm2Vw5v9ceQLew {
NI state;
NIM_BOOL init_done;
tyObject_ChoiceWithEmptySeq__t7AEMm29aSJZlarP2nlNXPg ch;
tyObject_EmptySeq__uQOC49aSxZzQKcPkzjyqKvw em;
};
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 tyObject_Og_Context__bxoIigb1FBm2Vw5v9ceQLew context__eZjCef5qtZfly1K38Gq64Q = {0, NIM_FALSE, {0, {0, {}, 0, {NIM_FALSE}}}, {}}
;
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) {
{
}
}
```
2024-06-11T10:27:42
2024-06-11T10:27:42
0 (0 bytes)
```cpp
#define NIM_INTBITS 64
#include "nimbase.h"
#define nimfr_(x, y)
#define nimln_(x, y)
typedef struct tyObject_Og_Context__bxoIigb1FBm2Vw5v9ceQLew tyObject_Og_Context__bxoIigb1FBm2Vw5v9ceQLew;
typedef struct tyObject_ChoiceWithEmptySeq__t7AEMm29aSJZlarP2nlNXPg tyObject_ChoiceWithEmptySeq__t7AEMm29aSJZlarP2nlNXPg;
typedef union tyObject_INNER_C_UNION__nSy3jrICR0lkSmOVKZWCMw tyObject_INNER_C_UNION__nSy3jrICR0lkSmOVKZWCMw;
typedef struct tyObject_EmptySeq__uQOC49aSxZzQKcPkzjyqKvw tyObject_EmptySeq__uQOC49aSxZzQKcPkzjyqKvw;
typedef struct tyObject_ChoiceWithEmptySeq_d__hy9agYq3kWtyifGrTP355nw tyObject_ChoiceWithEmptySeq_d__hy9agYq3kWtyifGrTP355nw;
typedef NU8 tyEnum_ChoiceWithEmptySeq_selection__gM43DRIqTgBba2IBkbSf2Q;
struct tyObject_EmptySeq__uQOC49aSxZzQKcPkzjyqKvw {
char dummy;
};
struct tyObject_ChoiceWithEmptySeq_d__hy9agYq3kWtyifGrTP355nw {
NIM_BOOL a;
};
union tyObject_INNER_C_UNION__nSy3jrICR0lkSmOVKZWCMw {
NIM_CHAR a;
tyObject_EmptySeq__uQOC49aSxZzQKcPkzjyqKvw b;
NU8 c;
tyObject_ChoiceWithEmptySeq_d__hy9agYq3kWtyifGrTP355nw d;
};
struct tyObject_ChoiceWithEmptySeq__t7AEMm29aSJZlarP2nlNXPg {
tyEnum_ChoiceWithEmptySeq_selection__gM43DRIqTgBba2IBkbSf2Q kind;
tyObject_INNER_C_UNION__nSy3jrICR0lkSmOVKZWCMw u;
};
struct tyObject_Og_Context__bxoIigb1FBm2Vw5v9ceQLew {
NI state;
NIM_BOOL init_done;
tyObject_ChoiceWithEmptySeq__t7AEMm29aSJZlarP2nlNXPg ch;
tyObject_EmptySeq__uQOC49aSxZzQKcPkzjyqKvw em;
};
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 tyObject_Og_Context__bxoIigb1FBm2Vw5v9ceQLew context__eZjCef5qtZfly1K38Gq64Q = {0, NIM_FALSE, {0, {0, {}, 0, {NIM_FALSE}}}, {}}
;
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) {
{
}
}
```
2024-06-11T10:27:45
2024-06-11T10:27:45
86.45 Kb (88,520 bytes)
```cpp
#define NIM_INTBITS 64
#include "nimbase.h"
#include 2024-06-11T10:27:47
2024-06-11T10:27:47
11.4.0
14.0.0
20.3
2024-06-11T10:26:59Z
2
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 29 minutes
bisecting 5949
commits at 199
commits per second
What happened?
I have encountered this issue (#10815) or something related in my project with the following example code:
The generated C code attempts to initialize the Object as:
{0, NIM_FALSE, {0, {0, {}, 0, {NIM_FALSE}}}, {}}
while it should in fact be:{0, NIM_FALSE, {0, 0}, {}}
. It tries to populate the Union as if it is a regular object, while it should only initialize a single field.This bug does not occur when manually initializing the Union:
Nim Version
Nim Compiler Version 1.6.8 [Linux: amd64] Compiled at 2022-09-27 Copyright (c) 2006-2021 by Andreas Rumpf
git hash: c9f46ca8c9eeca8b5f68591b1abe14b962f80a4c active boot switches: -d:release
Current Standard Output Logs
Additional Information
Related Issue: #10815 Platform: Linux Debian 11
(Kernel Version: 5.10.0-17-amd64)