Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling a proc with importcpp and constructor pragma generate invalid C++ code #22370

Open
demotomohiro opened this issue Aug 3, 2023 · 6 comments

Comments

@demotomohiro
Copy link
Contributor

Description

When importing C++ classes/structs and calling it's constructor to initialize module scope variable with other imported C++ classes/structs, Nim generates C++ code incorrectly.
Example code
testbugcpp.nim:

{.emit:"""
  struct Foo {
    int x;
  };

  struct Bar {
    Bar(Foo f): f(f) {}

    Foo f;
  };
""".}

type
  Foo {.importcpp.} = object
    x: cint

  Bar {.importcpp.} = object

proc constructBar(f: Foo): Bar {.importcpp: "Bar(@)", constructor.}

var b = constructBar(Foo(x: 1))

Compiled it with nim cpp testbugcpp.nim and got error from backend gcc.

Nim Version

Nim Compiler Version 2.1.1 [Linux: amd64]
Compiled at 2023-08-02
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: da36888
active boot switches: -d:release

Current Output

/tmp/nimcache123/testbugcpp/debug/@mtestbugcpp.nim.cpp:51:36: error: ‘T1_’ was not declared in this scope
   51 | N_LIB_PRIVATE Bar b__testbugcpp_u6(T1_);

Expected Output

No compile error from backend C++ compiler.

Possible Solution

No response

Additional Information

In Nim generated C++ code, variable b__testbugcpp_u6 is declared outside of functions, and calls constructor with variable T1_.
But T1_ is not declared there.

N_LIB_PRIVATE Bar b__testbugcpp_u6(T1_);

It is declared in NimMainModule function and it is not accessible from outside of functions.

N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) {
{
	Foo T1_{};
	nimfr_("testbugcpp", "/home/player/worktmpfs/testnim/testbugcpp.nim");
	T1_.x = ((int)1);
	nimlf_(21, "/home/player/worktmpfs/testnim/testbugcpp.nim");
	popFrame();
}
}

Nim should generate code like:

N_LIB_PRIVATE Bar b__testbugcpp_u6(Foo{(int)1});

Declaring the variable inside a procedure doesn't produce any error.

{.emit:"""
  struct Foo {
    int x;
  };

  struct Bar {
    Bar(Foo f): f(f) {}

    Foo f;
  };
""".}

type
  Foo {.importcpp.} = object
    x: cint

  Bar {.importcpp.} = object

proc constructBar(f: Foo): Bar {.importcpp: "Bar(@)", constructor.}

proc main =
  var b = constructBar(Foo(x: 1))

main()
@juancarlospaco
Copy link
Collaborator

!nim cpp --gc:arc

{.emit:"""
struct Foo {
  int x;
};
struct Bar {
  Bar(Foo f): f(f) {}
  Foo f;
};""".}

type
  Foo {.importcpp.} = object
    x: cint
  Bar {.importcpp.} = object

proc constructBar(f: Foo): Bar {.importcpp: "Bar(@)", constructor.}
var b = constructBar(Foo(x: 1))

@github-actions
Copy link
Contributor

github-actions bot commented Aug 3, 2023

@juancarlospaco (contributor)

devel :-1: FAIL

Output

Error: Command failed: nim cpp --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off  --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
command line(1, 2) Warning: `gc:option` is deprecated; use `mm:option` instead [Deprecated]
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:48:30: error: ‘T1_’ was not declared in this scope
   48 | N_LIB_PRIVATE Bar b__temp_u6(T1_);
      |                              ^~~
Error: execution of an external compiler program 'g++ -c -std=gnu++17 -funsigned-char  -w -fmax-errors=3 -fpermissive -pthread   -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-08-03T18:17:57Z
  • Started 2023-08-03T18:18:45
  • Finished 2023-08-03T18:18:46
  • Duration 1 minute
  • Commands nim cpp --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

Filesize 0 bytes
#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 Foo {
  int x;
};
struct Bar {
  Bar(Foo f): f(f) {}
  Foo f;
};
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u3737)(void);
static N_INLINE(void, popFrame)(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);
N_LIB_PRIVATE Bar b__temp_u6(T1_);
extern NIM_THREADVAR TFrame* framePtr__system_u3217;
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
	{
		if (!(framePtr__system_u3217 == ((TFrame*) NIM_NIL))) goto LA3_;
{		(*s_p0).calldepth = ((NI16)0);
}	}
	goto LA1_;
LA3_: ;
	{
		(*s_p0).calldepth = (NI16)((*framePtr__system_u3217).calldepth + ((NI16)1));
	}
LA1_: ;
	(*s_p0).prev = framePtr__system_u3217;
	framePtr__system_u3217 = s_p0;
	{
		if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
{		callDepthLimitReached__system_u3737();
}	}
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
	framePtr__system_u3217 = (*framePtr__system_u3217).prev;
}
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) {
{
	Foo T1_{};
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
	T1_.x = ((int)1);
	popFrame();
}
}

AST

stable :-1: FAIL

Output

Error: Command failed: nim cpp --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off  --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
command line(1, 2) Warning: `gc:option` is deprecated; use `mm:option` instead [Deprecated]
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:48:30: error: ‘T1_’ was not declared in this scope
   48 | N_LIB_PRIVATE Bar b__temp_u6(T1_);
      |                              ^~~
Error: execution of an external compiler program 'g++ -c -std=gnu++17 -funsigned-char  -w -fmax-errors=3 -fpermissive -pthread   -I/home/runner/.choosenim/toolchains/nim-2.0.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-08-03T18:17:57Z
  • Started 2023-08-03T18:18:47
  • Finished 2023-08-03T18:18:48
  • Duration 1 minute
  • Commands nim cpp --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

Filesize 0 bytes
#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 Foo {
  int x;
};
struct Bar {
  Bar(Foo f): f(f) {}
  Foo f;
};
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u3737)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystematsexceptionsdotnim_DatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
N_LIB_PRIVATE Bar b__temp_u6(T1_);
extern NIM_THREADVAR TFrame* framePtr__system_u3217;
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
	{
		if (!(framePtr__system_u3217 == ((TFrame*) NIM_NIL))) goto LA3_;
{		(*s_p0).calldepth = ((NI16)0);
}	}
	goto LA1_;
LA3_: ;
	{
		(*s_p0).calldepth = (NI16)((*framePtr__system_u3217).calldepth + ((NI16)1));
	}
LA1_: ;
	(*s_p0).prev = framePtr__system_u3217;
	framePtr__system_u3217 = s_p0;
	{
		if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
{		callDepthLimitReached__system_u3737();
}	}
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
	framePtr__system_u3217 = (*framePtr__system_u3217).prev;
}
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;
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystematsexceptionsdotnim_DatInit000();
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000();
	(*inner)();
#else
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystematsexceptionsdotnim_DatInit000();
	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) {
{
	Foo T1_{};
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
	T1_.x = ((int)1);
	popFrame();
}
}

AST

1.6.0 :-1: FAIL

Output

Error: Command failed: nim cpp --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off  --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:45:19: error: no matching function for call to ‘Bar::Bar()’
   45 | N_LIB_PRIVATE Bar b_temp_6;
      |                   ^~~~~~~~
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:35:3: note: candidate: ‘Bar::Bar(Foo)’
   35 |   Bar(Foo f): f(f) {}
      |   ^~~
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:35:3: note:   candidate expects 1 argument, 0 provided
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:34:8: note: candidate: ‘constexpr Bar::Bar(const Bar&)’
   34 | struct Bar {
      |        ^~~
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:34:8: note:   candidate expects 1 argument, 0 provided
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:34:8: note: candidate: ‘constexpr Bar::Bar(Bar&&)’
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:34:8: note:   candidate expects 1 argument, 0 provided
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-08-03T18:17:57Z
  • Started 2023-08-03T18:18:51
  • Finished 2023-08-03T18:18:52
  • Duration 1 minute
  • Commands nim cpp --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

Filesize 0 bytes
#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 Foo {
  int x;
};
struct Bar {
  Bar(Foo f): f(f) {}
  Foo f;
};
static N_INLINE(void, initStackBottomWith)(void* locals);
static N_INLINE(void, nimFrame)(TFrame* s);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached_system_3580)(void);
static N_INLINE(void, popFrame)(void);
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 Bar b_temp_6;
extern TFrame* framePtr_system_3135;
extern TFrame* framePtr_system_3135;
extern TFrame* framePtr_system_3135;
extern TFrame* framePtr_system_3135;
extern TFrame* framePtr_system_3135;
extern TFrame* framePtr_system_3135;
static N_INLINE(void, initStackBottomWith)(void* locals) {
}
static N_INLINE(void, nimFrame)(TFrame* s) {
	{
		if (!(framePtr_system_3135 == ((TFrame*) NIM_NIL))) goto LA3_;
{		(*s).calldepth = ((NI16) 0);
}	}
	goto LA1_;
	LA3_: ;
	{
		(*s).calldepth = (NI16)((*framePtr_system_3135).calldepth + ((NI16) 1));
	}
	LA1_: ;
	(*s).prev = framePtr_system_3135;
	framePtr_system_3135 = s;
	{
		if (!((*s).calldepth == ((NI16) 2000))) goto LA8_;
{		callDepthLimitReached_system_3580();
}	}
	LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
	framePtr_system_3135 = (*framePtr_system_3135).prev;
}
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();
	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) {
{
	Foo T1_;
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
	T1_.x = ((int) 1);
	b_temp_6 = Bar(T1_);
	popFrame();
}
}

AST

1.4.0 :-1: FAIL

Output

Error: Command failed: nim cpp --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off  --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:55:19: error: no matching function for call to ‘Bar::Bar()’
   55 | N_LIB_PRIVATE Bar b__iHlVDQBNmXEkRnHxFLlelA;
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:43:3: note: candidate: ‘Bar::Bar(Foo)’
   43 |   Bar(Foo f): f(f) {}
      |   ^~~
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:43:3: note:   candidate expects 1 argument, 0 provided
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:42:8: note: candidate: ‘constexpr Bar::Bar(const Bar&)’
   42 | struct Bar {
      |        ^~~
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:42:8: note:   candidate expects 1 argument, 0 provided
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:42:8: note: candidate: ‘constexpr Bar::Bar(Bar&&)’
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:42:8: note:   candidate expects 1 argument, 0 provided
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-08-03T18:17:57Z
  • Started 2023-08-03T18:18:55
  • Finished 2023-08-03T18:18:56
  • Duration 1 minute
  • Commands nim cpp --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

Filesize 0 bytes
#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 Foo {
  int x;
};
struct Bar {
  Bar(Foo f): f(f) {}
  Foo f;
};
static N_INLINE(void, initStackBottomWith)(void* locals);
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, systemDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);

N_LIB_PRIVATE Bar b__iHlVDQBNmXEkRnHxFLlelA;
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, initStackBottomWith)(void* locals) {
}
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 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();
	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) {
{
	Foo T1_;
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
	T1_.x = ((int) 1);
	b__iHlVDQBNmXEkRnHxFLlelA = Bar(T1_);
	popFrame();
}
}

AST

1.2.0 :-1: FAIL

Output

Error: Command failed: nim cpp --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off  --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:47:19: error: no matching function for call to ‘Bar::Bar()’
   47 | N_LIB_PRIVATE Bar b__iHlVDQBNmXEkRnHxFLlelA;
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:37:3: note: candidate: ‘Bar::Bar(Foo)’
   37 |   Bar(Foo f): f(f) {}
      |   ^~~
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:37:3: note:   candidate expects 1 argument, 0 provided
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:36:8: note: candidate: ‘constexpr Bar::Bar(const Bar&)’
   36 | struct Bar {
      |        ^~~
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:36:8: note:   candidate expects 1 argument, 0 provided
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:36:8: note: candidate: ‘constexpr Bar::Bar(Bar&&)’
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:36:8: note:   candidate expects 1 argument, 0 provided
Error: execution of an external compiler program 'g++ -c  -w -w -fpermissive  -std=gnu++14 -funsigned-char  -I/home/runner/.choosenim/toolchains/nim-1.2.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-08-03T18:17:57Z
  • Started 2023-08-03T18:19:13
  • Finished 2023-08-03T18:19:13
  • Duration 1 minute
  • Commands nim cpp --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

Filesize 0 bytes
#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 Foo {
  int x;
};
struct Bar {
  Bar(Foo f): f(f) {}
  Foo f;
};
static N_INLINE(void, initStackBottomWith)(void* locals);
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, systemDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
N_LIB_PRIVATE Bar b__iHlVDQBNmXEkRnHxFLlelA;
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, initStackBottomWith)(void* locals) {
}
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 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) {
{
	Foo T1_;
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
	T1_.x = ((int) 1);
	b__iHlVDQBNmXEkRnHxFLlelA = Bar(T1_);
	popFrame();
}
}

AST

1.0.0 :-1: FAIL

Output

Error: Command failed: nim cpp --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off  --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
command line(1, 2) Error: 'none', 'boehm' or 'refc' expected, but 'arc' found

Stats

  • Created 2023-08-03T18:17:57Z
  • Started 2023-08-03T18:19:25
  • Finished 2023-08-03T18:19:25
  • Duration now
  • Commands nim cpp --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

Filesize 0 bytes
#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 Foo {
  int x;
};
struct Bar {
  Bar(Foo f): f(f) {}
  Foo f;
};
static N_INLINE(void, initStackBottomWith)(void* locals);
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, systemDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
N_LIB_PRIVATE Bar b__iHlVDQBNmXEkRnHxFLlelA;
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, initStackBottomWith)(void* locals) {
}
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 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) {
{
	Foo T1_;
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
	T1_.x = ((int) 1);
	b__iHlVDQBNmXEkRnHxFLlelA = Bar(T1_);
	popFrame();
}
}

AST

0.20.2 :-1: FAIL

Output

Error: Command failed: nim cpp --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off  --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
command line(1, 2) Error: 'none', 'boehm' or 'refc' expected, but 'arc' found

Stats

  • Created 2023-08-03T18:17:57Z
  • Started 2023-08-03T18:19:37
  • Finished 2023-08-03T18:19:37
  • Duration now
  • Commands nim cpp --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

Filesize 0 bytes
#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 Foo {
  int x;
};
struct Bar {
  Bar(Foo f): f(f) {}
  Foo f;
};
static N_INLINE(void, initStackBottomWith)(void* locals);
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, systemDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
N_LIB_PRIVATE Bar b__iHlVDQBNmXEkRnHxFLlelA;
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, initStackBottomWith)(void* locals) {
}
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 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) {
{
	Foo T1_;
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
	T1_.x = ((int) 1);
	b__iHlVDQBNmXEkRnHxFLlelA = Bar(T1_);
	popFrame();
}
}

AST

🤖 Bug found in 56 minutes bisecting 7 commits at 0 commits per second.

@juancarlospaco
Copy link
Collaborator

!nim cpp --gc:refc

{.emit:"""
struct Foo {
  int x;
};
struct Bar {
  Bar(Foo f): f(f) {}
  Foo f;
};""".}

type
  Foo {.importcpp.} = object
    x: cint
  Bar {.importcpp.} = object

proc constructBar(f: Foo): Bar {.importcpp: "Bar(@)", constructor.}
var b = constructBar(Foo(x: 1))

@github-actions
Copy link
Contributor

github-actions bot commented Aug 3, 2023

@juancarlospaco (contributor)

devel 👎 FAIL

Output

Error: Command failed: nim cpp --gc:refc --run  -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --styleCheck:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
command line(1, 2) Warning: `gc:option` is deprecated; use `mm:option` instead [Deprecated]
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:51:30: error: ‘T1_’ was not declared in this scope
   51 | N_LIB_PRIVATE Bar b__temp_u6(T1_);
      |                              ^~~
Error: execution of an external compiler program 'g++ -c -std=gnu++17 -funsigned-char  -w -fmax-errors=3 -fpermissive -pthread   -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

  • Started 2023-08-03T22:04:56
  • Finished 2023-08-03T22:04:59
  • Duration 2 minutes

IR

Compiled filesize 0 bytes (0 bytes)
#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 Foo {
  int x;
};
struct Bar {
  Bar(Foo f): f(f) {}
  Foo f;
};
static N_INLINE(void, initStackBottomWith)(void* locals_p0);
N_LIB_PRIVATE N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom_p0);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u3130)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystematsexceptionsdotnim_DatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystemdotnim_DatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
N_LIB_PRIVATE Bar b__temp_u6(T1_);
extern NIM_THREADVAR TFrame* framePtr__system_u2601;
static N_INLINE(void, initStackBottomWith)(void* locals_p0) {
	nimGC_setStackBottom(locals_p0);
}
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
	{
		if (!(framePtr__system_u2601 == ((TFrame*) NIM_NIL))) goto LA3_;
{		(*s_p0).calldepth = ((NI16)0);
}	}
	goto LA1_;
LA3_: ;
	{
		(*s_p0).calldepth = (NI16)((*framePtr__system_u2601).calldepth + ((NI16)1));
	}
LA1_: ;
	(*s_p0).prev = framePtr__system_u2601;
	framePtr__system_u2601 = s_p0;
	{
		if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
{		callDepthLimitReached__system_u3130();
}	}
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
	framePtr__system_u2601 = (*framePtr__system_u2601).prev;
}
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 1
	void (*volatile inner)(void);
	inner = PreMainInner;
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystematsexceptionsdotnim_DatInit000();
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystemdotnim_DatInit000();
	initStackBottomWith((void *)&inner);
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystemdotnim_Init000();
	(*inner)();
#else
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystematsexceptionsdotnim_DatInit000();
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystemdotnim_DatInit000();
	initStackBottomWith((void *)&inner);
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystemdotnim_Init000();
	PreMainInner();
#endif
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
	NimMainModule();
}
N_CDECL(void, NimMain)(void) {
#if 1
	void (*volatile inner)(void);
	PreMain();
	inner = NimMainInner;
	initStackBottomWith((void *)&inner);
	(*inner)();
#else
	PreMain();
	initStackBottomWith((void *)&inner);
	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) {
{
	Foo T1_{};
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
	T1_.x = ((int)1);
	popFrame();
}
}

AST

nnkStmtList.newTree(
  nnkPragma.newTree(
    nnkExprColonExpr.newTree(
      newIdentNode("emit"),
      newLit("  struct Foo {\n    int x;\n  };\n  struct Bar {\n    Bar(Foo f): f(f) {}\n    Foo f;\n  };")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      nnkPragmaExpr.newTree(
        newIdentNode("Foo"),
        nnkPragma.newTree(
          newIdentNode("importcpp")
        )
      ),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("x"),
            newIdentNode("cint"),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      nnkPragmaExpr.newTree(
        newIdentNode("Bar"),
        nnkPragma.newTree(
          newIdentNode("importcpp")
        )
      ),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        newEmptyNode()
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("constructBar"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("Bar"),
      nnkIdentDefs.newTree(
        newIdentNode("f"),
        newIdentNode("Foo"),
        newEmptyNode()
      )
    ),
    nnkPragma.newTree(
      nnkExprColonExpr.newTree(
        newIdentNode("importcpp"),
        newLit("Bar(@)")
      ),
      newIdentNode("constructor")
    ),
    newEmptyNode(),
    newEmptyNode()
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("b"),
      newEmptyNode(),
      nnkCall.newTree(
        newIdentNode("constructBar"),
        nnkObjConstr.newTree(
          newIdentNode("Foo"),
          nnkExprColonExpr.newTree(
            newIdentNode("x"),
            newLit(1)
          )
        )
      )
    )
  )
)
stable 👎 FAIL

Output

Error: Command failed: nim cpp --gc:refc --run  -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --styleCheck:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
command line(1, 2) Warning: `gc:option` is deprecated; use `mm:option` instead [Deprecated]
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:51:30: error: ‘T1_’ was not declared in this scope
   51 | N_LIB_PRIVATE Bar b__temp_u6(T1_);
      |                              ^~~
Error: execution of an external compiler program 'g++ -c -std=gnu++17 -funsigned-char  -w -fmax-errors=3 -fpermissive -pthread   -I/home/runner/.choosenim/toolchains/nim-2.0.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

  • Started 2023-08-03T22:04:59
  • Finished 2023-08-03T22:05:00
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)
#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 Foo {
  int x;
};
struct Bar {
  Bar(Foo f): f(f) {}
  Foo f;
};
static N_INLINE(void, initStackBottomWith)(void* locals_p0);
N_LIB_PRIVATE N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom_p0);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u3130)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystematsexceptionsdotnim_DatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_DatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
N_LIB_PRIVATE Bar b__temp_u6(T1_);
extern NIM_THREADVAR TFrame* framePtr__system_u2601;
static N_INLINE(void, initStackBottomWith)(void* locals_p0) {
	nimGC_setStackBottom(locals_p0);
}
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
	{
		if (!(framePtr__system_u2601 == ((TFrame*) NIM_NIL))) goto LA3_;
{		(*s_p0).calldepth = ((NI16)0);
}	}
	goto LA1_;
LA3_: ;
	{
		(*s_p0).calldepth = (NI16)((*framePtr__system_u2601).calldepth + ((NI16)1));
	}
LA1_: ;
	(*s_p0).prev = framePtr__system_u2601;
	framePtr__system_u2601 = s_p0;
	{
		if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
{		callDepthLimitReached__system_u3130();
}	}
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
	framePtr__system_u2601 = (*framePtr__system_u2601).prev;
}
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 1
	void (*volatile inner)(void);
	inner = PreMainInner;
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystematsexceptionsdotnim_DatInit000();
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_DatInit000();
	initStackBottomWith((void *)&inner);
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000();
	(*inner)();
#else
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystematsexceptionsdotnim_DatInit000();
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_DatInit000();
	initStackBottomWith((void *)&inner);
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000();
	PreMainInner();
#endif
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
	NimMainModule();
}
N_CDECL(void, NimMain)(void) {
#if 1
	void (*volatile inner)(void);
	PreMain();
	inner = NimMainInner;
	initStackBottomWith((void *)&inner);
	(*inner)();
#else
	PreMain();
	initStackBottomWith((void *)&inner);
	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) {
{
	Foo T1_{};
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
	T1_.x = ((int)1);
	popFrame();
}
}

AST

nnkStmtList.newTree(
  nnkPragma.newTree(
    nnkExprColonExpr.newTree(
      newIdentNode("emit"),
      newLit("  struct Foo {\n    int x;\n  };\n  struct Bar {\n    Bar(Foo f): f(f) {}\n    Foo f;\n  };")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      nnkPragmaExpr.newTree(
        newIdentNode("Foo"),
        nnkPragma.newTree(
          newIdentNode("importcpp")
        )
      ),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("x"),
            newIdentNode("cint"),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      nnkPragmaExpr.newTree(
        newIdentNode("Bar"),
        nnkPragma.newTree(
          newIdentNode("importcpp")
        )
      ),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        newEmptyNode()
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("constructBar"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("Bar"),
      nnkIdentDefs.newTree(
        newIdentNode("f"),
        newIdentNode("Foo"),
        newEmptyNode()
      )
    ),
    nnkPragma.newTree(
      nnkExprColonExpr.newTree(
        newIdentNode("importcpp"),
        newLit("Bar(@)")
      ),
      newIdentNode("constructor")
    ),
    newEmptyNode(),
    newEmptyNode()
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("b"),
      newEmptyNode(),
      nnkCall.newTree(
        newIdentNode("constructBar"),
        nnkObjConstr.newTree(
          newIdentNode("Foo"),
          nnkExprColonExpr.newTree(
            newIdentNode("x"),
            newLit(1)
          )
        )
      )
    )
  )
)
2.0.0 👎 FAIL

Output

Error: Command failed: nim cpp --gc:refc --run  -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --styleCheck:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
command line(1, 2) Warning: `gc:option` is deprecated; use `mm:option` instead [Deprecated]
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:51:30: error: ‘T1_’ was not declared in this scope
   51 | N_LIB_PRIVATE Bar b__temp_u6(T1_);
      |                              ^~~
Error: execution of an external compiler program 'g++ -c -std=gnu++17 -funsigned-char  -w -fmax-errors=3 -fpermissive -pthread   -I/home/runner/.choosenim/toolchains/nim-2.0.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

  • Started 2023-08-03T22:05:00
  • Finished 2023-08-03T22:05:01
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)
#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 Foo {
  int x;
};
struct Bar {
  Bar(Foo f): f(f) {}
  Foo f;
};
static N_INLINE(void, initStackBottomWith)(void* locals_p0);
N_LIB_PRIVATE N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom_p0);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u3130)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystematsexceptionsdotnim_DatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_DatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
N_LIB_PRIVATE Bar b__temp_u6(T1_);
extern NIM_THREADVAR TFrame* framePtr__system_u2601;
static N_INLINE(void, initStackBottomWith)(void* locals_p0) {
	nimGC_setStackBottom(locals_p0);
}
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
	{
		if (!(framePtr__system_u2601 == ((TFrame*) NIM_NIL))) goto LA3_;
{		(*s_p0).calldepth = ((NI16)0);
}	}
	goto LA1_;
LA3_: ;
	{
		(*s_p0).calldepth = (NI16)((*framePtr__system_u2601).calldepth + ((NI16)1));
	}
LA1_: ;
	(*s_p0).prev = framePtr__system_u2601;
	framePtr__system_u2601 = s_p0;
	{
		if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
{		callDepthLimitReached__system_u3130();
}	}
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
	framePtr__system_u2601 = (*framePtr__system_u2601).prev;
}
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 1
	void (*volatile inner)(void);
	inner = PreMainInner;
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystematsexceptionsdotnim_DatInit000();
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_DatInit000();
	initStackBottomWith((void *)&inner);
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000();
	(*inner)();
#else
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystematsexceptionsdotnim_DatInit000();
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_DatInit000();
	initStackBottomWith((void *)&inner);
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000();
	PreMainInner();
#endif
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
	NimMainModule();
}
N_CDECL(void, NimMain)(void) {
#if 1
	void (*volatile inner)(void);
	PreMain();
	inner = NimMainInner;
	initStackBottomWith((void *)&inner);
	(*inner)();
#else
	PreMain();
	initStackBottomWith((void *)&inner);
	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) {
{
	Foo T1_{};
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
	T1_.x = ((int)1);
	popFrame();
}
}

AST

nnkStmtList.newTree(
  nnkPragma.newTree(
    nnkExprColonExpr.newTree(
      newIdentNode("emit"),
      newLit("  struct Foo {\n    int x;\n  };\n  struct Bar {\n    Bar(Foo f): f(f) {}\n    Foo f;\n  };")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      nnkPragmaExpr.newTree(
        newIdentNode("Foo"),
        nnkPragma.newTree(
          newIdentNode("importcpp")
        )
      ),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("x"),
            newIdentNode("cint"),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      nnkPragmaExpr.newTree(
        newIdentNode("Bar"),
        nnkPragma.newTree(
          newIdentNode("importcpp")
        )
      ),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        newEmptyNode()
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("constructBar"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("Bar"),
      nnkIdentDefs.newTree(
        newIdentNode("f"),
        newIdentNode("Foo"),
        newEmptyNode()
      )
    ),
    nnkPragma.newTree(
      nnkExprColonExpr.newTree(
        newIdentNode("importcpp"),
        newLit("Bar(@)")
      ),
      newIdentNode("constructor")
    ),
    newEmptyNode(),
    newEmptyNode()
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("b"),
      newEmptyNode(),
      nnkCall.newTree(
        newIdentNode("constructBar"),
        nnkObjConstr.newTree(
          newIdentNode("Foo"),
          nnkExprColonExpr.newTree(
            newIdentNode("x"),
            newLit(1)
          )
        )
      )
    )
  )
)
1.6.0 👎 FAIL

Output

Error: Command failed: nim cpp --gc:refc --run  -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --styleCheck: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:46:19: error: no matching function for call to ‘Bar::Bar()’
   46 | N_LIB_PRIVATE Bar b_temp_6;
      |                   ^~~~~~~~
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:35:3: note: candidate: ‘Bar::Bar(Foo)’
   35 |   Bar(Foo f): f(f) {}
      |   ^~~
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:35:3: note:   candidate expects 1 argument, 0 provided
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:34:8: note: candidate: ‘constexpr Bar::Bar(const Bar&)’
   34 | struct Bar {
      |        ^~~
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:34:8: note:   candidate expects 1 argument, 0 provided
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:34:8: note: candidate: ‘constexpr Bar::Bar(Bar&&)’
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:34:8: note:   candidate expects 1 argument, 0 provided
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

  • Started 2023-08-03T22:05:03
  • Finished 2023-08-03T22:05:04
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)
#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 Foo {
  int x;
};
struct Bar {
  Bar(Foo f): f(f) {}
  Foo f;
};
static N_INLINE(void, initStackBottomWith)(void* locals);
N_LIB_PRIVATE N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom);
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, systemDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
N_LIB_PRIVATE Bar b_temp_6;
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, initStackBottomWith)(void* locals) {
	nimGC_setStackBottom(locals);
}
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 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) {
{
	Foo T1_;
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
	T1_.x = ((int) 1);
	b_temp_6 = Bar(T1_);
	popFrame();
}
}

AST

nnkStmtList.newTree(
  nnkPragma.newTree(
    nnkExprColonExpr.newTree(
      newIdentNode("emit"),
      newLit("  struct Foo {\n    int x;\n  };\n  struct Bar {\n    Bar(Foo f): f(f) {}\n    Foo f;\n  };")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      nnkPragmaExpr.newTree(
        newIdentNode("Foo"),
        nnkPragma.newTree(
          newIdentNode("importcpp")
        )
      ),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("x"),
            newIdentNode("cint"),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      nnkPragmaExpr.newTree(
        newIdentNode("Bar"),
        nnkPragma.newTree(
          newIdentNode("importcpp")
        )
      ),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        newEmptyNode()
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("constructBar"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("Bar"),
      nnkIdentDefs.newTree(
        newIdentNode("f"),
        newIdentNode("Foo"),
        newEmptyNode()
      )
    ),
    nnkPragma.newTree(
      nnkExprColonExpr.newTree(
        newIdentNode("importcpp"),
        newLit("Bar(@)")
      ),
      newIdentNode("constructor")
    ),
    newEmptyNode(),
    newEmptyNode()
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("b"),
      newEmptyNode(),
      nnkCall.newTree(
        newIdentNode("constructBar"),
        nnkObjConstr.newTree(
          newIdentNode("Foo"),
          nnkExprColonExpr.newTree(
            newIdentNode("x"),
            newLit(1)
          )
        )
      )
    )
  )
)
1.4.0 👎 FAIL

Output

Error: Command failed: nim cpp --gc:refc --run  -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --styleCheck: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:56:19: error: no matching function for call to ‘Bar::Bar()’
   56 | N_LIB_PRIVATE Bar b__iHlVDQBNmXEkRnHxFLlelA;
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:43:3: note: candidate: ‘Bar::Bar(Foo)’
   43 |   Bar(Foo f): f(f) {}
      |   ^~~
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:43:3: note:   candidate expects 1 argument, 0 provided
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:42:8: note: candidate: ‘constexpr Bar::Bar(const Bar&)’
   42 | struct Bar {
      |        ^~~
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:42:8: note:   candidate expects 1 argument, 0 provided
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:42:8: note: candidate: ‘constexpr Bar::Bar(Bar&&)’
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:42:8: note:   candidate expects 1 argument, 0 provided
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

  • Started 2023-08-03T22:05:06
  • Finished 2023-08-03T22:05:07
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)
#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 Foo {
  int x;
};
struct Bar {
  Bar(Foo f): f(f) {}
  Foo f;
};
static N_INLINE(void, initStackBottomWith)(void* locals);
N_LIB_PRIVATE N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom);
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, systemDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);

N_LIB_PRIVATE Bar b__iHlVDQBNmXEkRnHxFLlelA;
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, initStackBottomWith)(void* locals) {
	nimGC_setStackBottom(locals);
}
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 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) {
{
	Foo T1_;
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
	T1_.x = ((int) 1);
	b__iHlVDQBNmXEkRnHxFLlelA = Bar(T1_);
	popFrame();
}
}

AST

nnkStmtList.newTree(
  nnkPragma.newTree(
    nnkExprColonExpr.newTree(
      newIdentNode("emit"),
      newLit("  struct Foo {\n    int x;\n  };\n  struct Bar {\n    Bar(Foo f): f(f) {}\n    Foo f;\n  };")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      nnkPragmaExpr.newTree(
        newIdentNode("Foo"),
        nnkPragma.newTree(
          newIdentNode("importcpp")
        )
      ),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("x"),
            newIdentNode("cint"),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      nnkPragmaExpr.newTree(
        newIdentNode("Bar"),
        nnkPragma.newTree(
          newIdentNode("importcpp")
        )
      ),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        newEmptyNode()
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("constructBar"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("Bar"),
      nnkIdentDefs.newTree(
        newIdentNode("f"),
        newIdentNode("Foo"),
        newEmptyNode()
      )
    ),
    nnkPragma.newTree(
      nnkExprColonExpr.newTree(
        newIdentNode("importcpp"),
        newLit("Bar(@)")
      ),
      newIdentNode("constructor")
    ),
    newEmptyNode(),
    newEmptyNode()
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("b"),
      newEmptyNode(),
      nnkCall.newTree(
        newIdentNode("constructBar"),
        nnkObjConstr.newTree(
          newIdentNode("Foo"),
          nnkExprColonExpr.newTree(
            newIdentNode("x"),
            newLit(1)
          )
        )
      )
    )
  )
)
1.2.0 👎 FAIL

Output

Error: Command failed: nim cpp --gc:refc --run  -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --styleCheck: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:48:19: error: no matching function for call to ‘Bar::Bar()’
   48 | N_LIB_PRIVATE Bar b__iHlVDQBNmXEkRnHxFLlelA;
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:37:3: note: candidate: ‘Bar::Bar(Foo)’
   37 |   Bar(Foo f): f(f) {}
      |   ^~~
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:37:3: note:   candidate expects 1 argument, 0 provided
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:36:8: note: candidate: ‘constexpr Bar::Bar(const Bar&)’
   36 | struct Bar {
      |        ^~~
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:36:8: note:   candidate expects 1 argument, 0 provided
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:36:8: note: candidate: ‘constexpr Bar::Bar(Bar&&)’
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:36:8: note:   candidate expects 1 argument, 0 provided
Error: execution of an external compiler program 'g++ -c  -w -w -fpermissive  -std=gnu++14 -funsigned-char  -I/home/runner/.choosenim/toolchains/nim-1.2.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

  • Started 2023-08-03T22:05:23
  • Finished 2023-08-03T22:05:23
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)
#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 Foo {
  int x;
};
struct Bar {
  Bar(Foo f): f(f) {}
  Foo f;
};
static N_INLINE(void, initStackBottomWith)(void* locals);
N_LIB_PRIVATE N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom);
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, systemDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
N_LIB_PRIVATE Bar b__iHlVDQBNmXEkRnHxFLlelA;
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, initStackBottomWith)(void* locals) {
	nimGC_setStackBottom(locals);
}
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 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) {
{
	Foo T1_;
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
	T1_.x = ((int) 1);
	b__iHlVDQBNmXEkRnHxFLlelA = Bar(T1_);
	popFrame();
}
}

AST

nnkStmtList.newTree(
  nnkPragma.newTree(
    nnkExprColonExpr.newTree(
      newIdentNode("emit"),
      newLit("  struct Foo {\n    int x;\n  };\n  struct Bar {\n    Bar(Foo f): f(f) {}\n    Foo f;\n  };")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      nnkPragmaExpr.newTree(
        newIdentNode("Foo"),
        nnkPragma.newTree(
          newIdentNode("importcpp")
        )
      ),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("x"),
            newIdentNode("cint"),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      nnkPragmaExpr.newTree(
        newIdentNode("Bar"),
        nnkPragma.newTree(
          newIdentNode("importcpp")
        )
      ),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        newEmptyNode()
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("constructBar"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("Bar"),
      nnkIdentDefs.newTree(
        newIdentNode("f"),
        newIdentNode("Foo"),
        newEmptyNode()
      )
    ),
    nnkPragma.newTree(
      nnkExprColonExpr.newTree(
        newIdentNode("importcpp"),
        newLit("Bar(@)")
      ),
      newIdentNode("constructor")
    ),
    newEmptyNode(),
    newEmptyNode()
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("b"),
      newEmptyNode(),
      nnkCall.newTree(
        newIdentNode("constructBar"),
        nnkObjConstr.newTree(
          newIdentNode("Foo"),
          nnkExprColonExpr.newTree(
            newIdentNode("x"),
            newLit(1)
          )
        )
      )
    )
  )
)
1.0.0 👎 FAIL

Output

Error: Command failed: nim cpp --gc:refc --run  -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --styleCheck:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
Error: execution of an external compiler program 'g++ -c  -w -w -fpermissive  -I/home/runner/.choosenim/toolchains/nim-1.0.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

/home/runner/work/Nim/Nim/@mtemp.nim.cpp:48:5: error: no matching function for call to ‘Bar::Bar()’
   48 | Bar b__iHlVDQBNmXEkRnHxFLlelA;
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:37:3: note: candidate: ‘Bar::Bar(Foo)’
   37 |   Bar(Foo f): f(f) {}
      |   ^~~
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:37:3: note:   candidate expects 1 argument, 0 provided
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:36:8: note: candidate: ‘constexpr Bar::Bar(const Bar&)’
   36 | struct Bar {
      |        ^~~
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:36:8: note:   candidate expects 1 argument, 0 provided
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:36:8: note: candidate: ‘constexpr Bar::Bar(Bar&&)’
/home/runner/work/Nim/Nim/@mtemp.nim.cpp:36:8: note:   candidate expects 1 argument, 0 provided

Stats

  • Started 2023-08-03T22:05:36
  • Finished 2023-08-03T22:05:36
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)
#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 Foo {
  int x;
};
struct Bar {
  Bar(Foo f): f(f) {}
  Foo f;
};
static N_INLINE(void, initStackBottomWith)(void* locals);
N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom);
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, systemDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
Bar b__iHlVDQBNmXEkRnHxFLlelA;
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, initStackBottomWith)(void* locals) {
	nimGC_setStackBottom(locals);
}
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;
}
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) {
{
	Foo T1_;
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
	T1_.x = ((int) 1);
	b__iHlVDQBNmXEkRnHxFLlelA = Bar(T1_);
	popFrame();
}
}

AST

nnkStmtList.newTree(
  nnkPragma.newTree(
    nnkExprColonExpr.newTree(
      newIdentNode("emit"),
      newLit("  struct Foo {\n    int x;\n  };\n  struct Bar {\n    Bar(Foo f): f(f) {}\n    Foo f;\n  };")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      nnkPragmaExpr.newTree(
        newIdentNode("Foo"),
        nnkPragma.newTree(
          newIdentNode("importcpp")
        )
      ),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("x"),
            newIdentNode("cint"),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      nnkPragmaExpr.newTree(
        newIdentNode("Bar"),
        nnkPragma.newTree(
          newIdentNode("importcpp")
        )
      ),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        newEmptyNode()
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("constructBar"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("Bar"),
      nnkIdentDefs.newTree(
        newIdentNode("f"),
        newIdentNode("Foo"),
        newEmptyNode()
      )
    ),
    nnkPragma.newTree(
      nnkExprColonExpr.newTree(
        newIdentNode("importcpp"),
        newLit("Bar(@)")
      ),
      newIdentNode("constructor")
    ),
    newEmptyNode(),
    newEmptyNode()
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("b"),
      newEmptyNode(),
      nnkCall.newTree(
        newIdentNode("constructBar"),
        nnkObjConstr.newTree(
          newIdentNode("Foo"),
          nnkExprColonExpr.newTree(
            newIdentNode("x"),
            newLit(1)
          )
        )
      )
    )
  )
)
0.20.2 👎 FAIL

Output

Error: Command failed: nim cpp --gc:refc --run  -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --styleCheck:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
Error: execution of an external compiler program 'g++ -c  -w -w -fpermissive  -I/home/runner/.choosenim/toolchains/nim-0.20.2/lib -I/home/runner/work/Nim/Nim -o /home/runner/work/Nim/Nim/temp.nim.cpp.o /home/runner/work/Nim/Nim/temp.nim.cpp' failed with exit code: 1

/home/runner/work/Nim/Nim/temp.nim.cpp:48:5: error: no matching function for call to ‘Bar::Bar()’
   48 | Bar b_iHlVDQBNmXEkRnHxFLlelA;
      |     ^~~~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/Nim/Nim/temp.nim.cpp:37:3: note: candidate: ‘Bar::Bar(Foo)’
   37 |   Bar(Foo f): f(f) {}
      |   ^~~
/home/runner/work/Nim/Nim/temp.nim.cpp:37:3: note:   candidate expects 1 argument, 0 provided
/home/runner/work/Nim/Nim/temp.nim.cpp:36:8: note: candidate: ‘constexpr Bar::Bar(const Bar&)’
   36 | struct Bar {
      |        ^~~
/home/runner/work/Nim/Nim/temp.nim.cpp:36:8: note:   candidate expects 1 argument, 0 provided
/home/runner/work/Nim/Nim/temp.nim.cpp:36:8: note: candidate: ‘constexpr Bar::Bar(Bar&&)’
/home/runner/work/Nim/Nim/temp.nim.cpp:36:8: note:   candidate expects 1 argument, 0 provided

Stats

  • Started 2023-08-03T22:05:47
  • Finished 2023-08-03T22:05:47
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)
#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 Foo {
  int x;
};
struct Bar {
  Bar(Foo f): f(f) {}
  Foo f;
};
static N_INLINE(void, initStackBottomWith)(void* locals);
N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom);
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, systemDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
Bar b__iHlVDQBNmXEkRnHxFLlelA;
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, initStackBottomWith)(void* locals) {
	nimGC_setStackBottom(locals);
}
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;
}
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) {
{
	Foo T1_;
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
	T1_.x = ((int) 1);
	b__iHlVDQBNmXEkRnHxFLlelA = Bar(T1_);
	popFrame();
}
}

AST

nnkStmtList.newTree(
  nnkPragma.newTree(
    nnkExprColonExpr.newTree(
      newIdentNode("emit"),
      newLit("  struct Foo {\n    int x;\n  };\n  struct Bar {\n    Bar(Foo f): f(f) {}\n    Foo f;\n  };")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      nnkPragmaExpr.newTree(
        newIdentNode("Foo"),
        nnkPragma.newTree(
          newIdentNode("importcpp")
        )
      ),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("x"),
            newIdentNode("cint"),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      nnkPragmaExpr.newTree(
        newIdentNode("Bar"),
        nnkPragma.newTree(
          newIdentNode("importcpp")
        )
      ),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        newEmptyNode()
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("constructBar"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("Bar"),
      nnkIdentDefs.newTree(
        newIdentNode("f"),
        newIdentNode("Foo"),
        newEmptyNode()
      )
    ),
    nnkPragma.newTree(
      nnkExprColonExpr.newTree(
        newIdentNode("importcpp"),
        newLit("Bar(@)")
      ),
      newIdentNode("constructor")
    ),
    newEmptyNode(),
    newEmptyNode()
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("b"),
      newEmptyNode(),
      nnkCall.newTree(
        newIdentNode("constructBar"),
        nnkObjConstr.newTree(
          newIdentNode("Foo"),
          nnkExprColonExpr.newTree(
            newIdentNode("x"),
            newLit(1)
          )
        )
      )
    )
  )
)
Stats
  • GCC (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0
  • LibC (Ubuntu GLIBC 2.35-0ubuntu3.1) 2.35
  • Valgrind 3.18.1
  • NodeJS 18.17.0
  • Linux 5.15.0-1042-
  • Created 2023-08-03T22:04:15Z
  • Issue Comments 3
  • Commands nim cpp --gc:refc --run -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --styleCheck:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

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

@bung87
Copy link
Collaborator

bung87 commented Aug 10, 2023

either support default constructor so can separate the declaration and initialization, or treat the constructor arguments as global too.

@demotomohiro
Copy link
Contributor Author

either support default constructor so can separate the declaration and initialization

When wrapping an existing C++ library that cannot be edited and a class has constructors with parameters but doesn't have one without parameter, you cannot separate the declaration and initialization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants