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

std/pegs with nim cpp --mm:orc --exceptions:goto creates invalid C++ #22101

Closed
tersec opened this issue Jun 15, 2023 · 7 comments · Fixed by #24531
Closed

std/pegs with nim cpp --mm:orc --exceptions:goto creates invalid C++ #22101

tersec opened this issue Jun 15, 2023 · 7 comments · Fixed by #24531

Comments

@tersec
Copy link
Contributor

tersec commented Jun 15, 2023

Description

import std/pegs
discard pegs.peg("")

Compiled with either:
nim cpp --mm:orc --exceptions:goto repro.nim
or
nim cpp --mm:arc --exceptions:goto repro.nim

creates C++ code which g++ 12.3 states is invalid.

Nim Version

Current devel:

Nim Compiler Version 1.9.3 [Linux: amd64]
Compiled at 2023-06-15
Copyright (c) 2006-2023 by Andreas Rumpf

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

Debian's current 1.6:

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

active boot switches: -d:release
g++ (Debian 12.3.0-3) 12.3.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Current Output

CC: Nim/lib/system/exceptions.nim
CC: Nim/lib/std/private/digitsutils.nim
CC: Nim/lib/std/assertions.nim
CC: Nim/lib/system/dollars.nim
CC: Nim/lib/system.nim
CC: Nim/lib/pure/strutils.nim
CC: Nim/lib/pure/pegs.nim
CC: repro.nim
.cache/nim/repro_d/@mNim@slib@spure@spegs.nim.cpp: In function ‘tyObject_NonTerminalObj__3NeutKyjmri5aWXhMzCWFw* getNonTerminal__pureZpegs_u4986(tyObject_PegParser__bnL79cpRlZGwqTbySns8Nsg&, NimStringV2)’:
.cache/nim/repro_d/@mNim@slib@spure@spegs.nim.cpp:4762:17: error: jump to label ‘LA1_’
 4762 |                 LA1_:;
      |                 ^~~~
.cache/nim/repro_d/@mNim@slib@spure@spegs.nim.cpp:4740:120: note:   from here
 4740 |                                 if (nimAddInt(res, ((NI)1), &TM__YGOrctedenU9ao6jM7xmy6g_230)) { raiseOverflow(); goto LA1_;
      |                                                                                                                        ^~~~
.cache/nim/repro_d/@mNim@slib@spure@spegs.nim.cpp:4752:12: note:   crosses initialization of ‘NI T12_’
 4752 |         NI T12_ = getColumn__pureZpegs_u4121((&p_p0));
      |            ^~~~
.cache/nim/repro_d/@mNim@slib@spure@spegs.nim.cpp:4751:12: note:   crosses initialization of ‘NI T11_’
 4751 |         NI T11_ = getLine__pureZpegs_u4124((&p_p0));
      |            ^~~~
.cache/nim/repro_d/@mNim@slib@spure@spegs.nim.cpp:4762:17: error: jump to label ‘LA1_’
 4762 |                 LA1_:;
      |                 ^~~~
.cache/nim/repro_d/@mNim@slib@spure@spegs.nim.cpp:4728:66: note:   from here
 4728 |                                 if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
      |                                                                  ^~~~
.cache/nim/repro_d/@mNim@slib@spure@spegs.nim.cpp:4752:12: note:   crosses initialization of ‘NI T12_’
 4752 |         NI T12_ = getColumn__pureZpegs_u4121((&p_p0));
      |            ^~~~
.cache/nim/repro_d/@mNim@slib@spure@spegs.nim.cpp:4751:12: note:   crosses initialization of ‘NI T11_’
 4751 |         NI T11_ = getLine__pureZpegs_u4124((&p_p0));
      |            ^~~~
.cache/nim/repro_d/@mNim@slib@spure@spegs.nim.cpp:4762:17: error: jump to label ‘LA1_’
 4762 |                 LA1_:;
      |                 ^~~~
.cache/nim/repro_d/@mNim@slib@spure@spegs.nim.cpp:4725:117: note:   from here
 4725 |                                 if (i < 0 || i >= p_p0.nonterms.len){ raiseIndexError2(i,p_p0.nonterms.len-1); goto LA1_;
      |                                                                                                                     ^~~~
.cache/nim/repro_d/@mNim@slib@spure@spegs.nim.cpp:4752:12: note:   crosses initialization of ‘NI T12_’
 4752 |         NI T12_ = getColumn__pureZpegs_u4121((&p_p0));
      |            ^~~~
.cache/nim/repro_d/@mNim@slib@spure@spegs.nim.cpp:4751:12: note:   crosses initialization of ‘NI T11_’
 4751 |         NI T11_ = getLine__pureZpegs_u4124((&p_p0));
      |            ^~~~
Error: execution of an external compiler program 'g++ -c -std=gnu++17 -funsigned-char  -w -fmax-errors=3 -fpermissive -pthread   -INim/lib -I/home/user -o .cache/nim/repro_d/@mNim@slib@spure@spegs.nim.cpp.o .cache/nim/repro_d/@mNim@slib@spure@spegs.nim.cpp' failed with exit code: 1

Expected Output

Not invalid generated C++ code.

Possible Solution

No response

Additional Information

No response

@juancarlospaco
Copy link
Collaborator

!nim cpp --gc:arc

import std/pegs
discard pegs.peg("")

@github-actions
Copy link
Contributor

github-actions bot commented Jul 5, 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 --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off  --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
command line(1, 2) Warning: `gc:option` is deprecated; use `mm:option` instead [Deprecated]
/home/runner/work/Nim/Nim/temp.nim temp
/home/runner/.choosenim/toolchains/nim-#devel/lib/pure/pegs.nim peg
/home/runner/.choosenim/toolchains/nim-#devel/lib/pure/pegs.nim parsePeg
/home/runner/.choosenim/toolchains/nim-#devel/lib/pure/pegs.nim rawParse
/home/runner/.choosenim/toolchains/nim-#devel/lib/pure/pegs.nim parseExpr
/home/runner/.choosenim/toolchains/nim-#devel/lib/pure/pegs.nim seqExpr
/home/runner/.choosenim/toolchains/nim-#devel/lib/pure/pegs.nim primary
/home/runner/.choosenim/toolchains/nim-#devel/lib/pure/pegs.nim pegError
Error: unhandled exception: pattern(1, 1) Error: expression expected, but found: [EOF]� [EInvalidPeg]
Error: execution of an external program failed: '/home/runner/work/Nim/Nim/temp'

Stats

  • Created 2023-07-05T01:10:54Z
  • Started 2023-07-05T01:11:19
  • Finished 2023-07-05T01:11:21
  • Duration 2 minutes
  • Commands nim cpp --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#include <exception>
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
#define nimfr_(proc, file) \
  TFrame FR_; \
  FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
  #define nimfrs_(proc, file, slots, length) \
    struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename;NI len;VarSlot s[slots];} FR_; \
    FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
  #define nimln_(n) \
    FR_.line = n;
  #define nimlf_(n, file) \
    FR_.line = n; FR_.filename = file;
struct tyObject_Peg__eHZ39baPVS6Ex9aCbakMpOLA;
struct NimStrPayload;
struct NimStringV2;
struct tyObject_NonTerminalObj__YJQBzPMiCVZ9a9aFblGw9bz9aQ;
struct tySequence__FP9cpgC5P8HWlLP22NHEOaw;
struct tySequence__FP9cpgC5P8HWlLP22NHEOaw_Content;
struct Exception;
struct RootObj;
struct TNimTypeV2;
struct tySequence__9bNRJkU9cJnNkESCDTQ7DgcQ;
struct tySequence__9bNRJkU9cJnNkESCDTQ7DgcQ_Content;
struct tyObject_StackTraceEntry__2Xjg6E7TZG7p9bcgUNTKHrg;
typedef NU8 tyEnum_PegKind__8HD2K9c0ElHMxe2OEKoQqRg;
struct NimStrPayload {
	NI cap;
	NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
	NI len;
	NimStrPayload* p;
};
struct tySequence__FP9cpgC5P8HWlLP22NHEOaw {
  NI len; tySequence__FP9cpgC5P8HWlLP22NHEOaw_Content* p;
};
struct tyObject_Peg__eHZ39baPVS6Ex9aCbakMpOLA {
	tyEnum_PegKind__8HD2K9c0ElHMxe2OEKoQqRg kind;
union{
	NimStringV2 term;
	NIM_CHAR ch;
	NU8* charChoice;
	tyObject_NonTerminalObj__YJQBzPMiCVZ9a9aFblGw9bz9aQ* nt;
	NI index;
	tySequence__FP9cpgC5P8HWlLP22NHEOaw sons;
};
};
struct TNimTypeV2 {
	void* destructor;
	NI size;
	NI16 align;
	NI16 depth;
	NU32* display;
	void* traceImpl;
	void* typeInfoV1;
	NI flags;
};
struct RootObj {
TNimTypeV2* m_type;
};
struct tySequence__9bNRJkU9cJnNkESCDTQ7DgcQ {
  NI len; tySequence__9bNRJkU9cJnNkESCDTQ7DgcQ_Content* p;
};
struct Exception : public RootObj {
	Exception* parent;
	NCSTRING name;
	NimStringV2 message;
	tySequence__9bNRJkU9cJnNkESCDTQ7DgcQ trace;
	Exception* up;
};
struct tySequence__FP9cpgC5P8HWlLP22NHEOaw_Content { NI cap; tyObject_Peg__eHZ39baPVS6Ex9aCbakMpOLA data[SEQ_DECL_SIZE]; };
struct tyObject_StackTraceEntry__2Xjg6E7TZG7p9bcgUNTKHrg {
	NCSTRING procname;
	NI line;
	NCSTRING filename;
};
struct tySequence__9bNRJkU9cJnNkESCDTQ7DgcQ_Content { NI cap; tyObject_StackTraceEntry__2Xjg6E7TZG7p9bcgUNTKHrg data[SEQ_DECL_SIZE]; };
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1);
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2);
N_LIB_PRIVATE N_NIMCALL(void, peg__pureZpegs_u4958)(NimStringV2 pattern_p0, tyObject_Peg__eHZ39baPVS6Ex9aCbakMpOLA* Result);
static N_INLINE(TFrame*, getFrame)(void);
static N_INLINE(void, setFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___pureZpegs_u232)(tyObject_Peg__eHZ39baPVS6Ex9aCbakMpOLA& dest_p0);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u3620)(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, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatspureatspegsdotnim_DatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
static const struct {
  NI cap; NIM_CHAR data[0+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 0 | NIM_STRLIT_FLAG, "" };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {0, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
extern TFrame* framePtr__system_u3100;
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2) {
	void* T1_ = memset(a_p0, v_p1, ((size_t) (size_p2)));
}
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1) {
	nimSetMem__systemZmemory_u7(p_p0, ((int)0), size_p1);
}
static N_INLINE(TFrame*, getFrame)(void) {
	TFrame* result;
	result = (TFrame*)0;
	result = framePtr__system_u3100;
	return result;
}
static N_INLINE(void, setFrame)(TFrame* s_p0) {
	framePtr__system_u3100 = s_p0;
}
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
	{
		if (!(framePtr__system_u3100 == ((TFrame*) NIM_NIL))) goto LA3_;
{		(*s_p0).calldepth = ((NI16)0);
}	}
	goto LA1_;
LA3_: ;
	{
		(*s_p0).calldepth = (NI16)((*framePtr__system_u3100).calldepth + ((NI16)1));
	}
LA1_: ;
	(*s_p0).prev = framePtr__system_u3100;
	framePtr__system_u3100 = s_p0;
	{
		if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
{		callDepthLimitReached__system_u3620();
}	}
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
	framePtr__system_u3100 = (*framePtr__system_u3100).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();
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatspureatspegsdotnim_DatInit000();
	(*inner)();
#else
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystematsexceptionsdotnim_DatInit000();
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystemdotnim_Init000();
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatspureatspegsdotnim_DatInit000();
	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) {
{
	tyObject_Peg__eHZ39baPVS6Ex9aCbakMpOLA colontmpD_;
	TFrame* _nimCurFrame;
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
	_nimCurFrame = getFrame();
	nimZeroMem((void*)(&colontmpD_), sizeof(tyObject_Peg__eHZ39baPVS6Ex9aCbakMpOLA));
	std::exception_ptr T2_;
	try {
	peg__pureZpegs_u4958(TM__SRd76hP9cMfCzdUO857UhQQ_3, (&colontmpD_));
	(void)(colontmpD_);
	}
	catch (Exception* T3_) {
	setFrame(_nimCurFrame);
	T2_ = std::current_exception();
	}
	catch (...) {
		setFrame(_nimCurFrame);
		T2_ = std::current_exception();
	}
	{
		eqdestroy___pureZpegs_u232(colontmpD_);
		if (T2_) std::rethrow_exception(T2_);
	}
	popFrame();
}
}

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("pegs")
    )
  ),
  nnkDiscardStmt.newTree(
    nnkCall.newTree(
      nnkDotExpr.newTree(
        newIdentNode("pegs"),
        newIdentNode("peg")
      ),
      newLit("")
    )
  )
)
stable :-1: FAIL

Output

Error: Command failed: nim cpp --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off  --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/temp.nim temp
/home/runner/.choosenim/toolchains/nim-1.6.14/lib/pure/pegs.nim peg
/home/runner/.choosenim/toolchains/nim-1.6.14/lib/pure/pegs.nim parsePeg
/home/runner/.choosenim/toolchains/nim-1.6.14/lib/pure/pegs.nim rawParse
/home/runner/.choosenim/toolchains/nim-1.6.14/lib/pure/pegs.nim parseExpr
/home/runner/.choosenim/toolchains/nim-1.6.14/lib/pure/pegs.nim seqExpr
/home/runner/.choosenim/toolchains/nim-1.6.14/lib/pure/pegs.nim primary
/home/runner/.choosenim/toolchains/nim-1.6.14/lib/pure/pegs.nim pegError
Error: unhandled exception: pattern(1, 1) Error: expression expected, but found: [EOF]� [EInvalidPeg]
Error: execution of an external program failed: '/home/runner/work/Nim/Nim/temp '

Stats

  • Created 2023-07-05T01:10:54Z
  • Started 2023-07-05T01:11:22
  • Finished 2023-07-05T01:11:23
  • Duration 1 minute
  • Commands nim cpp --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#include <exception>
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
  #  define nimfr_(proc, file) \
      TFrame FR_; \
      FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
  #  define nimfrs_(proc, file, slots, length) \
      struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename; NI len; VarSlot s[slots];} FR_; \
      FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
  #  define nimln_(n, file) \
      FR_.line = n; FR_.filename = file;
  struct tyObject_Peg__9bJDkQSmj1I1wfUxN9ago6Ng;
struct NimStrPayload;
struct NimStringV2;
struct tyObject_NonTerminalObj__bwEun9bfpvLl9c51oMJLaVgg;
struct tySequence__WKST2D9aCGgAJ583IpgK3Kw;
struct tySequence__WKST2D9aCGgAJ583IpgK3Kw_Content;
struct Exception;
struct RootObj;
struct TNimTypeV2;
struct tySequence__SeNI9cjAwgnSTUG8yHFeMew;
struct tySequence__SeNI9cjAwgnSTUG8yHFeMew_Content;
struct tyObject_StackTraceEntry__HK6FWWCL5W1d6sCawft2nw;
typedef NU8 tyEnum_PegKind__xa5Xl9a1Gk4UhGAzDuMAYPg;
struct NimStrPayload {
NI cap;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
NI len;
NimStrPayload* p;
};
struct tySequence__WKST2D9aCGgAJ583IpgK3Kw {
  NI len; tySequence__WKST2D9aCGgAJ583IpgK3Kw_Content* p;
};
struct tyObject_Peg__9bJDkQSmj1I1wfUxN9ago6Ng {
tyEnum_PegKind__xa5Xl9a1Gk4UhGAzDuMAYPg kind;
union{
NimStringV2 term;
NIM_CHAR ch;
NU8* charChoice;
tyObject_NonTerminalObj__bwEun9bfpvLl9c51oMJLaVgg* nt;
NI index;
tySequence__WKST2D9aCGgAJ583IpgK3Kw sons;
};
};
struct TNimTypeV2 {
void* destructor;
NI size;
NI align;
NCSTRING name;
void* traceImpl;
void* typeInfoV1;
NI flags;
};
struct RootObj {
TNimTypeV2* m_type;
};
struct tySequence__SeNI9cjAwgnSTUG8yHFeMew {
  NI len; tySequence__SeNI9cjAwgnSTUG8yHFeMew_Content* p;
};
struct Exception : public RootObj {
Exception* parent;
NCSTRING name;
NimStringV2 message;
tySequence__SeNI9cjAwgnSTUG8yHFeMew trace;
Exception* up;
};
#ifndef tySequence__WKST2D9aCGgAJ583IpgK3Kw_Content_PP
#define tySequence__WKST2D9aCGgAJ583IpgK3Kw_Content_PP
struct tySequence__WKST2D9aCGgAJ583IpgK3Kw_Content { NI cap; tyObject_Peg__9bJDkQSmj1I1wfUxN9ago6Ng data[SEQ_DECL_SIZE];};
#endif
      struct tyObject_StackTraceEntry__HK6FWWCL5W1d6sCawft2nw {
NCSTRING procname;
NI line;
NCSTRING filename;
};
#ifndef tySequence__SeNI9cjAwgnSTUG8yHFeMew_Content_PP
#define tySequence__SeNI9cjAwgnSTUG8yHFeMew_Content_PP
struct tySequence__SeNI9cjAwgnSTUG8yHFeMew_Content { NI cap; tyObject_StackTraceEntry__HK6FWWCL5W1d6sCawft2nw data[SEQ_DECL_SIZE];};
#endif
      static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem__systemZmemory_7)(void* a, int v, NI size);
N_LIB_PRIVATE N_NIMCALL(void, peg__pureZpegs_4359)(NimStringV2 pattern, tyObject_Peg__9bJDkQSmj1I1wfUxN9ago6Ng* Result);
static N_INLINE(TFrame*, getFrame)(void);
static N_INLINE(void, setFrame)(TFrame* s);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___pureZpegs_178)(tyObject_Peg__9bJDkQSmj1I1wfUxN9ago6Ng& dest);
static N_INLINE(void, nimFrame)(TFrame* s);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_3636)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_DatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatspureatspegsdotnim_DatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
static const struct {
  NI cap; NIM_CHAR data[0+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 0 | NIM_STRLIT_FLAG, "" };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {0, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
extern TFrame* framePtr__system_3187;
extern TFrame* framePtr__system_3187;
extern TFrame* framePtr__system_3187;
extern TFrame* framePtr__system_3187;
extern TFrame* framePtr__system_3187;
extern TFrame* framePtr__system_3187;
extern TFrame* framePtr__system_3187;
extern TFrame* framePtr__system_3187;
static N_INLINE(void, nimSetMem__systemZmemory_7)(void* a, int v, NI size) {
	void* T1_ = memset(a, v, ((size_t) (size)));
}
static N_INLINE(void, nimZeroMem)(void* p, NI size) {
	nimSetMem__systemZmemory_7(p, ((int) 0), size);
}
static N_INLINE(TFrame*, getFrame)(void) {
	TFrame* result;
	result = (TFrame*)0;
	result = framePtr__system_3187;
	return result;
}
static N_INLINE(void, setFrame)(TFrame* s) {
	framePtr__system_3187 = s;
}
static N_INLINE(void, nimFrame)(TFrame* s) {
	{
		if (!(framePtr__system_3187 == ((TFrame*) NIM_NIL))) goto LA3_;
{		(*s).calldepth = ((NI16) 0);
}	}
	goto LA1_;
	LA3_: ;
	{
		(*s).calldepth = (NI16)((*framePtr__system_3187).calldepth + ((NI16) 1));
	}
	LA1_: ;
	(*s).prev = framePtr__system_3187;
	framePtr__system_3187 = s;
	{
		if (!((*s).calldepth == ((NI16) 2000))) goto LA8_;
{		callDepthLimitReached__system_3636();
}	}
	LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
	framePtr__system_3187 = (*framePtr__system_3187).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) {
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_DatInit000();
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_Init000();
	atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatspureatspegsdotnim_DatInit000();
	PreMainInner();
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
	NimMainModule();
}
N_CDECL(void, NimMain)(void) {
	PreMain();
	NimMainInner();
}
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) {
{
	tyObject_Peg__9bJDkQSmj1I1wfUxN9ago6Ng colontmpD_;
	TFrame* _nimCurFrame;
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
	std::exception_ptr T2_ = nullptr;	_nimCurFrame = getFrame();
	nimZeroMem((void*)(&colontmpD_), sizeof(tyObject_Peg__9bJDkQSmj1I1wfUxN9ago6Ng));
	try {
	peg__pureZpegs_4359(TM__SRd76hP9cMfCzdUO857UhQQ_3, (&colontmpD_));
	(void)(colontmpD_);
	}
	catch (Exception* T3_) {
	setFrame(_nimCurFrame);
	T2_ = std::current_exception();
	}
	catch (...) {		setFrame(_nimCurFrame);
		T2_ = std::current_exception();
	}
	{
		eqdestroy___pureZpegs_178(colontmpD_);
		if (T2_) std::rethrow_exception(T2_);
	}
	popFrame();
}
}

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("pegs")
    )
  ),
  nnkDiscardStmt.newTree(
    nnkCall.newTree(
      nnkDotExpr.newTree(
        newIdentNode("pegs"),
        newIdentNode("peg")
      ),
      newLit("")
    )
  )
)
1.6.0 :-1: FAIL

Output

Error: Command failed: nim cpp --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off  --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/temp.nim temp
/home/runner/.choosenim/toolchains/nim-1.6.0/lib/pure/pegs.nim peg
/home/runner/.choosenim/toolchains/nim-1.6.0/lib/pure/pegs.nim parsePeg
/home/runner/.choosenim/toolchains/nim-1.6.0/lib/pure/pegs.nim rawParse
/home/runner/.choosenim/toolchains/nim-1.6.0/lib/pure/pegs.nim parseExpr
/home/runner/.choosenim/toolchains/nim-1.6.0/lib/pure/pegs.nim seqExpr
/home/runner/.choosenim/toolchains/nim-1.6.0/lib/pure/pegs.nim primary
/home/runner/.choosenim/toolchains/nim-1.6.0/lib/pure/pegs.nim pegError
Error: unhandled exception: pattern(1, 1) Error: expression expected, but found: [EOF]� [EInvalidPeg]
Error: execution of an external program failed: '/home/runner/work/Nim/Nim/temp '

Stats

  • Created 2023-07-05T01:10:54Z
  • Started 2023-07-05T01:11:26
  • Finished 2023-07-05T01:11:27
  • Duration 1 minute
  • Commands nim cpp --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#include <exception>
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
  #  define nimfr_(proc, file) \
      TFrame FR_; \
      FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
  #  define nimfrs_(proc, file, slots, length) \
      struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename; NI len; VarSlot s[slots];} FR_; \
      FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
  #  define nimln_(n, file) \
      FR_.line = n; FR_.filename = file;
  struct tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ;
struct NimStrPayload;
struct NimStringV2;
struct tyObject_NonTerminalObj__VMn2tGRm8B9a9cqMEec3KPEA;
struct tySequence__5DSB9bTgCQCsIApS5TVlG8g;
struct tySequence__5DSB9bTgCQCsIApS5TVlG8g_Content;
struct Exception;
struct RootObj;
struct TNimTypeV2;
struct tySequence__uB9b75OUPRENsBAu4AnoePA;
struct tySequence__uB9b75OUPRENsBAu4AnoePA_Content;
struct tyObject_StackTraceEntry__oLyohQ7O2XOvGnflOss8EA;
typedef NU8 tyEnum_PegKind__r9a6rAhGclsLWkBysfmtr6Q;
struct NimStrPayload {
NI cap;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
NI len;
NimStrPayload* p;
};
struct tySequence__5DSB9bTgCQCsIApS5TVlG8g {
  NI len; tySequence__5DSB9bTgCQCsIApS5TVlG8g_Content* p;
};
struct tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ {
tyEnum_PegKind__r9a6rAhGclsLWkBysfmtr6Q kind;
union{
NimStringV2 term;
NIM_CHAR ch;
NU8* charChoice;
tyObject_NonTerminalObj__VMn2tGRm8B9a9cqMEec3KPEA* nt;
NI index;
tySequence__5DSB9bTgCQCsIApS5TVlG8g sons;
};
};
struct TNimTypeV2 {
void* destructor;
NI size;
NI align;
NCSTRING name;
void* traceImpl;
void* typeInfoV1;
NI flags;
};
struct RootObj {
TNimTypeV2* m_type;
};
struct tySequence__uB9b75OUPRENsBAu4AnoePA {
  NI len; tySequence__uB9b75OUPRENsBAu4AnoePA_Content* p;
};
struct Exception : public RootObj {
Exception* parent;
NCSTRING name;
NimStringV2 message;
tySequence__uB9b75OUPRENsBAu4AnoePA trace;
Exception* up;
};
#ifndef tySequence__5DSB9bTgCQCsIApS5TVlG8g_Content_PP
#define tySequence__5DSB9bTgCQCsIApS5TVlG8g_Content_PP
struct tySequence__5DSB9bTgCQCsIApS5TVlG8g_Content { NI cap; tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ data[SEQ_DECL_SIZE];};
#endif
      struct tyObject_StackTraceEntry__oLyohQ7O2XOvGnflOss8EA {
NCSTRING procname;
NI line;
NCSTRING filename;
};
#ifndef tySequence__uB9b75OUPRENsBAu4AnoePA_Content_PP
#define tySequence__uB9b75OUPRENsBAu4AnoePA_Content_PP
struct tySequence__uB9b75OUPRENsBAu4AnoePA_Content { NI cap; tyObject_StackTraceEntry__oLyohQ7O2XOvGnflOss8EA data[SEQ_DECL_SIZE];};
#endif
      static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem_systemZmemory_7)(void* a, int v, NI size);
N_LIB_PRIVATE N_NIMCALL(void, peg_pureZpegs_4285)(NimStringV2 pattern, tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ* Result);
static N_INLINE(TFrame*, getFrame)(void);
static N_INLINE(void, setFrame)(TFrame* s);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy__pureZpegs_178)(tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ& dest);
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, stdlib_pegsDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
static const struct {
  NI cap; NIM_CHAR data[0+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 0 | NIM_STRLIT_FLAG, "" };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {0, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
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;
extern TFrame* framePtr_system_3135;
extern TFrame* framePtr_system_3135;
static N_INLINE(void, nimSetMem_systemZmemory_7)(void* a, int v, NI size) {
	void* T1_ = memset(a, v, ((size_t) (size)));
}
static N_INLINE(void, nimZeroMem)(void* p, NI size) {
	nimSetMem_systemZmemory_7(p, ((int) 0), size);
}
static N_INLINE(TFrame*, getFrame)(void) {
	TFrame* result;
	result = (TFrame*)0;
	result = framePtr_system_3135;
	return result;
}
static N_INLINE(void, setFrame)(TFrame* s) {
	framePtr_system_3135 = s;
}
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();
	stdlib_pegsDatInit000();
	(*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) {
{
	tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ colontmpD_;
	TFrame* _nimCurFrame;
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
	std::exception_ptr T2_ = nullptr;	_nimCurFrame = getFrame();
	nimZeroMem((void*)(&colontmpD_), sizeof(tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ));
	try {
	peg_pureZpegs_4285(TM__SRd76hP9cMfCzdUO857UhQQ_3, (&colontmpD_));
	(void)(colontmpD_);
	}
	catch (Exception* T3_) {
	setFrame(_nimCurFrame);
	T2_ = std::current_exception();
	}
	catch (...) {		setFrame(_nimCurFrame);
		T2_ = std::current_exception();
	}
	{
		eqdestroy__pureZpegs_178(colontmpD_);
		if (T2_) std::rethrow_exception(T2_);
	}
	popFrame();
}
}

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("pegs")
    )
  ),
  nnkDiscardStmt.newTree(
    nnkCall.newTree(
      nnkDotExpr.newTree(
        newIdentNode("pegs"),
        newIdentNode("peg")
      ),
      newLit("")
    )
  )
)
1.4.0 :-1: FAIL

Output

Error: Command failed: nim cpp --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off  --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/temp.nim temp
/home/runner/.choosenim/toolchains/nim-1.4.0/lib/pure/pegs.nim peg
/home/runner/.choosenim/toolchains/nim-1.4.0/lib/pure/pegs.nim parsePeg
/home/runner/.choosenim/toolchains/nim-1.4.0/lib/pure/pegs.nim rawParse
/home/runner/.choosenim/toolchains/nim-1.4.0/lib/pure/pegs.nim parseExpr
/home/runner/.choosenim/toolchains/nim-1.4.0/lib/pure/pegs.nim seqExpr
/home/runner/.choosenim/toolchains/nim-1.4.0/lib/pure/pegs.nim primary
/home/runner/.choosenim/toolchains/nim-1.4.0/lib/pure/pegs.nim pegError
Error: unhandled exception: pattern(1, 1) Error: expression expected, but found: [EOF]Error: execution of an external program failed: '/home/runner/work/Nim/Nim/temp '

Stats

  • Created 2023-07-05T01:10:54Z
  • Started 2023-07-05T01:11:29
  • Finished 2023-07-05T01:11:30
  • Duration 1 minute
  • Commands nim cpp --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

#define NIM_INTBITS 64

#include "nimbase.h"
#include <string.h>
#include <exception>
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix

  #  define nimfr_(proc, file) \
      TFrame FR_; \
      FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
  #  define nimfrs_(proc, file, slots, length) \
      struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename; NI len; VarSlot s[slots];} FR_; \
      FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
  #  define nimln_(n, file) \
      FR_.line = n; FR_.filename = file;

struct tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ;
struct NimStrPayload;
struct NimStringV2;
struct tyObject_NonTerminalObj__VMn2tGRm8B9a9cqMEec3KPEA;
struct tySequence__5DSB9bTgCQCsIApS5TVlG8g;
struct tySequence__5DSB9bTgCQCsIApS5TVlG8g_Content;
struct Exception;
struct RootObj;
struct TNimTypeV2;
struct tySequence__uB9b75OUPRENsBAu4AnoePA;
struct tySequence__uB9b75OUPRENsBAu4AnoePA_Content;
struct tyObject_StackTraceEntry__oLyohQ7O2XOvGnflOss8EA;

typedef NU8 tyEnum_PegKind__r9a6rAhGclsLWkBysfmtr6Q;
struct NimStrPayload {
NI cap;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
NI len;
NimStrPayload* p;
};
struct tySequence__5DSB9bTgCQCsIApS5TVlG8g {
  NI len; tySequence__5DSB9bTgCQCsIApS5TVlG8g_Content* p;
};
struct tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ {
tyEnum_PegKind__r9a6rAhGclsLWkBysfmtr6Q kind;
union{
NimStringV2 term;
NIM_CHAR ch;
NU8* charChoice;
tyObject_NonTerminalObj__VMn2tGRm8B9a9cqMEec3KPEA* nt;
NI index;
tySequence__5DSB9bTgCQCsIApS5TVlG8g sons;
};
};
struct TNimTypeV2 {
void* destructor;
NI size;
NI align;
NCSTRING name;
void* traceImpl;
void* disposeImpl;
void* typeInfoV1;
};
struct RootObj {
TNimTypeV2* m_type;
};
struct tySequence__uB9b75OUPRENsBAu4AnoePA {
  NI len; tySequence__uB9b75OUPRENsBAu4AnoePA_Content* p;
};
struct Exception : public RootObj {
Exception* parent;
NCSTRING name;
NimStringV2 message;
tySequence__uB9b75OUPRENsBAu4AnoePA trace;
Exception* up;
};
#ifndef tySequence__5DSB9bTgCQCsIApS5TVlG8g_Content_PP
#define tySequence__5DSB9bTgCQCsIApS5TVlG8g_Content_PP
struct tySequence__5DSB9bTgCQCsIApS5TVlG8g_Content { NI cap; tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ data[SEQ_DECL_SIZE];};
#endif
      struct tyObject_StackTraceEntry__oLyohQ7O2XOvGnflOss8EA {
NCSTRING procname;
NI line;
NCSTRING filename;
};
#ifndef tySequence__uB9b75OUPRENsBAu4AnoePA_Content_PP
#define tySequence__uB9b75OUPRENsBAu4AnoePA_Content_PP
struct tySequence__uB9b75OUPRENsBAu4AnoePA_Content { NI cap; tyObject_StackTraceEntry__oLyohQ7O2XOvGnflOss8EA data[SEQ_DECL_SIZE];};
#endif

static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size);
N_LIB_PRIVATE N_NIMCALL(void, peg__43AZ7ZFAo8xUltgm3ekenw)(NimStringV2 pattern, tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ* Result);
static N_INLINE(TFrame*, getFrame)(void);
static N_INLINE(void, setFrame)(TFrame* s);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___uUSodrP7A4XpeMEslfRXgQ)(tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ& dest);
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, stdlib_pegsDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);

static const struct {
  NI cap; NIM_CHAR data[0+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 0 | NIM_STRLIT_FLAG, "" };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {0, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};

extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;

static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size) {
	void* T1_ = memset(a, v, ((size_t) (size)));
}
static N_INLINE(void, nimZeroMem)(void* p, NI size) {
	nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory(p, ((int) 0), size);
}
static N_INLINE(TFrame*, getFrame)(void) {
	TFrame* result;
	result = (TFrame*)0;
	result = framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
	return result;
}
static N_INLINE(void, setFrame)(TFrame* s) {
	framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw = s;
}
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();
	stdlib_pegsDatInit000();
	(*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) {
{
	tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ colontmpD_;
	TFrame* _nimCurFrame;
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
	std::exception_ptr T2_ = nullptr;	_nimCurFrame = getFrame();
	nimZeroMem((void*)(&colontmpD_), sizeof(tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ));
	try {
	peg__43AZ7ZFAo8xUltgm3ekenw(TM__SRd76hP9cMfCzdUO857UhQQ_3, (&colontmpD_));
	(void)(colontmpD_);
	}
	catch (Exception* T3_) {
	setFrame(_nimCurFrame);
	T2_ = std::current_exception();
	}
	catch (...) {		setFrame(_nimCurFrame);
		T2_ = std::current_exception();
	}
	{
		eqdestroy___uUSodrP7A4XpeMEslfRXgQ(colontmpD_);
		if (T2_) std::rethrow_exception(T2_);
	}
	popFrame();
}
}

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("pegs")
    )
  ),
  nnkDiscardStmt.newTree(
    nnkCall.newTree(
      nnkDotExpr.newTree(
        newIdentNode("pegs"),
        newIdentNode("peg")
      ),
      newLit("")
    )
  )
)
1.2.0 :-1: FAIL

Output

Error: Command failed: nim cpp --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off  --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/temp.nim temp
/home/runner/.choosenim/toolchains/nim-1.2.0/lib/pure/pegs.nim peg
/home/runner/.choosenim/toolchains/nim-1.2.0/lib/pure/pegs.nim parsePeg
/home/runner/.choosenim/toolchains/nim-1.2.0/lib/pure/pegs.nim rawParse
/home/runner/.choosenim/toolchains/nim-1.2.0/lib/pure/pegs.nim parseExpr
/home/runner/.choosenim/toolchains/nim-1.2.0/lib/pure/pegs.nim seqExpr
/home/runner/.choosenim/toolchains/nim-1.2.0/lib/pure/pegs.nim primary
/home/runner/.choosenim/toolchains/nim-1.2.0/lib/pure/pegs.nim pegError
Error: unhandled exception: pattern(1, 1) Error: expression expected, but found: [EOF]Error: execution of an external program failed: '/home/runner/work/Nim/Nim/temp '

Stats

  • Created 2023-07-05T01:10:54Z
  • Started 2023-07-05T01:11:46
  • Finished 2023-07-05T01:11:47
  • Duration 1 minute
  • Commands nim cpp --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#include <exception>
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
  #  define nimfr_(proc, file) \
      TFrame FR_; \
      FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
  #  define nimfrs_(proc, file, slots, length) \
      struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename; NI len; VarSlot s[slots];} FR_; \
      FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
  #  define nimln_(n, file) \
      FR_.line = n; FR_.filename = file;
  struct tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ;
struct NimStrPayload;
struct NimStringV2;
struct tyObject_NonTerminalObj__VMn2tGRm8B9a9cqMEec3KPEA;
struct tySequence__5DSB9bTgCQCsIApS5TVlG8g;
struct tySequence__5DSB9bTgCQCsIApS5TVlG8g_Content;
struct Exception;
struct RootObj;
struct TNimType;
struct tySequence__uB9b75OUPRENsBAu4AnoePA;
struct tySequence__uB9b75OUPRENsBAu4AnoePA_Content;
struct tyObject_StackTraceEntry__oLyohQ7O2XOvGnflOss8EA;
typedef NU8 tyEnum_PegKind__r9a6rAhGclsLWkBysfmtr6Q;
struct NimStrPayload {
NI cap;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
NI len;
NimStrPayload* p;
};
struct tySequence__5DSB9bTgCQCsIApS5TVlG8g {
  NI len; tySequence__5DSB9bTgCQCsIApS5TVlG8g_Content* p;
};
struct tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ {
tyEnum_PegKind__r9a6rAhGclsLWkBysfmtr6Q kind;
union{
NimStringV2 term;
NIM_CHAR ch;
NU8* charChoice;
tyObject_NonTerminalObj__VMn2tGRm8B9a9cqMEec3KPEA* nt;
NI index;
tySequence__5DSB9bTgCQCsIApS5TVlG8g sons;
};
};
struct TNimType {
void* destructor;
NI size;
NCSTRING name;
void* traceImpl;
void* disposeImpl;
};
struct RootObj {
TNimType* m_type;
};
struct tySequence__uB9b75OUPRENsBAu4AnoePA {
  NI len; tySequence__uB9b75OUPRENsBAu4AnoePA_Content* p;
};
struct Exception : public RootObj {
Exception* parent;
NCSTRING name;
NimStringV2 message;
tySequence__uB9b75OUPRENsBAu4AnoePA trace;
Exception* up;
};
#ifndef tySequence__5DSB9bTgCQCsIApS5TVlG8g_Content_PP
#define tySequence__5DSB9bTgCQCsIApS5TVlG8g_Content_PP
struct tySequence__5DSB9bTgCQCsIApS5TVlG8g_Content { NI cap; tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ data[SEQ_DECL_SIZE];};
#endif
      struct tyObject_StackTraceEntry__oLyohQ7O2XOvGnflOss8EA {
NCSTRING procname;
NI line;
NCSTRING filename;
};
#ifndef tySequence__uB9b75OUPRENsBAu4AnoePA_Content_PP
#define tySequence__uB9b75OUPRENsBAu4AnoePA_Content_PP
struct tySequence__uB9b75OUPRENsBAu4AnoePA_Content { NI cap; tyObject_StackTraceEntry__oLyohQ7O2XOvGnflOss8EA data[SEQ_DECL_SIZE];};
#endif
      static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size);
N_LIB_PRIVATE N_NIMCALL(void, eqsink___mimbQZhtftl1WKcoel6Bww)(tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ& dest, tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ src);
N_LIB_PRIVATE N_NIMCALL(void, peg__43AZ7ZFAo8xUltgm3ekenw)(NimStringV2 pattern, tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ* Result);
static N_INLINE(TFrame*, getFrame)(void);
static N_INLINE(void, setFrame)(TFrame* s);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___uUSodrP7A4XpeMEslfRXgQ)(tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ& dest);
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, stdlib_pegsDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
static const struct {
  NI cap; NIM_CHAR data[0+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 0 | NIM_STRLIT_FLAG, "" };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {0, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size) {
	void* T1_ = memset(a, v, ((size_t) (size)));
}
static N_INLINE(void, nimZeroMem)(void* p, NI size) {
	nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory(p, ((int) 0), size);
}
static N_INLINE(TFrame*, getFrame)(void) {
	TFrame* result;
	result = (TFrame*)0;
	result = framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
	return result;
}
static N_INLINE(void, setFrame)(TFrame* s) {
	framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw = s;
}
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();
	stdlib_pegsDatInit000();
	(*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) {
{
	tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ colontmpD_;
	TFrame* _nimCurFrame;
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
	_nimCurFrame = getFrame();
	nimZeroMem((void*)(&colontmpD_), sizeof(tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ));
	std::exception_ptr T2_ = nullptr;	try {
		tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ T4_;
		nimZeroMem((void*)(&T4_), sizeof(tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ));
		peg__43AZ7ZFAo8xUltgm3ekenw(TM__SRd76hP9cMfCzdUO857UhQQ_3, (&T4_));
		eqsink___mimbQZhtftl1WKcoel6Bww(colontmpD_, T4_);
		(void)(colontmpD_);
	}
	catch (Exception* T3_) {
	setFrame(_nimCurFrame);
	T2_ = std::current_exception();
	}
	catch (...) {		setFrame(_nimCurFrame);
		T2_ = std::current_exception();
	}
	{
		eqdestroy___uUSodrP7A4XpeMEslfRXgQ(colontmpD_);
		if (T2_) std::rethrow_exception(T2_);
	}
	popFrame();
}
}

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("pegs")
    )
  ),
  nnkDiscardStmt.newTree(
    nnkCall.newTree(
      nnkDotExpr.newTree(
        newIdentNode("pegs"),
        newIdentNode("peg")
      ),
      newLit("")
    )
  )
)
1.0.0 :-1: FAIL

Output

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

Stats

  • Created 2023-07-05T01:10:54Z
  • Started 2023-07-05T01:12:00
  • Finished 2023-07-05T01:12:00
  • Duration now
  • Commands nim cpp --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#include <exception>
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
  #  define nimfr_(proc, file) \
      TFrame FR_; \
      FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
  #  define nimfrs_(proc, file, slots, length) \
      struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename; NI len; VarSlot s[slots];} FR_; \
      FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
  #  define nimln_(n, file) \
      FR_.line = n; FR_.filename = file;
  struct tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ;
struct NimStrPayload;
struct NimStringV2;
struct tyObject_NonTerminalObj__VMn2tGRm8B9a9cqMEec3KPEA;
struct tySequence__5DSB9bTgCQCsIApS5TVlG8g;
struct tySequence__5DSB9bTgCQCsIApS5TVlG8g_Content;
struct Exception;
struct RootObj;
struct TNimType;
struct tySequence__uB9b75OUPRENsBAu4AnoePA;
struct tySequence__uB9b75OUPRENsBAu4AnoePA_Content;
struct tyObject_StackTraceEntry__oLyohQ7O2XOvGnflOss8EA;
typedef NU8 tyEnum_PegKind__r9a6rAhGclsLWkBysfmtr6Q;
struct NimStrPayload {
NI cap;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
NI len;
NimStrPayload* p;
};
struct tySequence__5DSB9bTgCQCsIApS5TVlG8g {
  NI len; tySequence__5DSB9bTgCQCsIApS5TVlG8g_Content* p;
};
struct tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ {
tyEnum_PegKind__r9a6rAhGclsLWkBysfmtr6Q kind;
union{
NimStringV2 term;
NIM_CHAR ch;
NU8* charChoice;
tyObject_NonTerminalObj__VMn2tGRm8B9a9cqMEec3KPEA* nt;
NI index;
tySequence__5DSB9bTgCQCsIApS5TVlG8g sons;
};
};
struct TNimType {
void* destructor;
NI size;
NCSTRING name;
void* traceImpl;
void* disposeImpl;
};
struct RootObj {
TNimType* m_type;
};
struct tySequence__uB9b75OUPRENsBAu4AnoePA {
  NI len; tySequence__uB9b75OUPRENsBAu4AnoePA_Content* p;
};
struct Exception : public RootObj {
Exception* parent;
NCSTRING name;
NimStringV2 message;
tySequence__uB9b75OUPRENsBAu4AnoePA trace;
Exception* up;
};
#ifndef tySequence__5DSB9bTgCQCsIApS5TVlG8g_Content_PP
#define tySequence__5DSB9bTgCQCsIApS5TVlG8g_Content_PP
struct tySequence__5DSB9bTgCQCsIApS5TVlG8g_Content { NI cap; tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ data[SEQ_DECL_SIZE];};
#endif
      struct tyObject_StackTraceEntry__oLyohQ7O2XOvGnflOss8EA {
NCSTRING procname;
NI line;
NCSTRING filename;
};
#ifndef tySequence__uB9b75OUPRENsBAu4AnoePA_Content_PP
#define tySequence__uB9b75OUPRENsBAu4AnoePA_Content_PP
struct tySequence__uB9b75OUPRENsBAu4AnoePA_Content { NI cap; tyObject_StackTraceEntry__oLyohQ7O2XOvGnflOss8EA data[SEQ_DECL_SIZE];};
#endif
      static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size);
N_LIB_PRIVATE N_NIMCALL(void, eqsink___mimbQZhtftl1WKcoel6Bww)(tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ& dest, tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ src);
N_LIB_PRIVATE N_NIMCALL(void, peg__43AZ7ZFAo8xUltgm3ekenw)(NimStringV2 pattern, tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ* Result);
static N_INLINE(TFrame*, getFrame)(void);
static N_INLINE(void, setFrame)(TFrame* s);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___uUSodrP7A4XpeMEslfRXgQ)(tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ& dest);
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, stdlib_pegsDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
static const struct {
  NI cap; NIM_CHAR data[0+1];
} TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 0 | NIM_STRLIT_FLAG, "" };
static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {0, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2};
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size) {
	void* T1_ = memset(a, v, ((size_t) (size)));
}
static N_INLINE(void, nimZeroMem)(void* p, NI size) {
	nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory(p, ((int) 0), size);
}
static N_INLINE(TFrame*, getFrame)(void) {
	TFrame* result;
	result = (TFrame*)0;
	result = framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
	return result;
}
static N_INLINE(void, setFrame)(TFrame* s) {
	framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw = s;
}
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();
	stdlib_pegsDatInit000();
	(*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) {
{
	tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ colontmpD_;
	TFrame* _nimCurFrame;
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
	_nimCurFrame = getFrame();
	nimZeroMem((void*)(&colontmpD_), sizeof(tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ));
	std::exception_ptr T2_ = nullptr;	try {
		tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ T4_;
		nimZeroMem((void*)(&T4_), sizeof(tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ));
		peg__43AZ7ZFAo8xUltgm3ekenw(TM__SRd76hP9cMfCzdUO857UhQQ_3, (&T4_));
		eqsink___mimbQZhtftl1WKcoel6Bww(colontmpD_, T4_);
		(void)(colontmpD_);
	}
	catch (Exception* T3_) {
	setFrame(_nimCurFrame);
	T2_ = std::current_exception();
	}
	catch (...) {		setFrame(_nimCurFrame);
		T2_ = std::current_exception();
	}
	{
		eqdestroy___uUSodrP7A4XpeMEslfRXgQ(colontmpD_);
		if (T2_) std::rethrow_exception(T2_);
	}
	popFrame();
}
}

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("pegs")
    )
  ),
  nnkDiscardStmt.newTree(
    nnkCall.newTree(
      nnkDotExpr.newTree(
        newIdentNode("pegs"),
        newIdentNode("peg")
      ),
      newLit("")
    )
  )
)
🤖 Bug found in 44 minutes bisecting 6 commits at 0 commits per second.

@juancarlospaco
Copy link
Collaborator

!nim cpp --gc:refc --exceptions:goto

import std/pegs
discard pegs.peg("")

@github-actions
Copy link
Contributor

github-actions bot commented Jul 5, 2023

@juancarlospaco (contributor)

devel :+1: OK

Output


Stats

  • Created 2023-07-05T01:41:35Z
  • Started 2023-07-05T01:42:08
  • Finished 2023-07-05T01:42:10
  • Duration 1 minute
  • Commands nim cpp --gc:refc --exceptions:goto --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
stable :+1: OK

Output


Stats

  • Created 2023-07-05T01:41:35Z
  • Started 2023-07-05T01:42:10
  • Finished 2023-07-05T01:42:11
  • Duration 1 minute
  • Commands nim cpp --gc:refc --exceptions:goto --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
1.6.0 :+1: OK

Output


Stats

  • Created 2023-07-05T01:41:35Z
  • Started 2023-07-05T01:42:14
  • Finished 2023-07-05T01:42:15
  • Duration 1 minute
  • Commands nim cpp --gc:refc --exceptions:goto --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
1.4.0 :-1: FAIL

Output

Error: Command failed: nim cpp --gc:refc --exceptions:goto --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off  --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
Segmentation fault (core dumped)
Error: execution of an external program failed: '/home/runner/work/Nim/Nim/temp '

Stats

  • Created 2023-07-05T01:41:35Z
  • Started 2023-07-05T01:42:18
  • Finished 2023-07-05T01:42:19
  • Duration 1 minute
  • Commands nim cpp --gc:refc --exceptions:goto --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

#define NIM_INTBITS 64

#include "nimbase.h"
#include <string.h>
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix

  #  define nimfr_(proc, file) \
      TFrame FR_; \
      FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
  #  define nimfrs_(proc, file, slots, length) \
      struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename; NI len; VarSlot s[slots];} FR_; \
      FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
  #  define nimln_(n, file) \
      FR_.line = n; FR_.filename = file;

struct NimStringDesc;
struct TGenericSeq;
struct tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ;
struct tyObject_NonTerminalObj__VMn2tGRm8B9a9cqMEec3KPEA;
struct tySequence__5DSB9bTgCQCsIApS5TVlG8g;

struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc : public TGenericSeq {
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef NU8 tyEnum_PegKind__r9a6rAhGclsLWkBysfmtr6Q;
struct tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ {
tyEnum_PegKind__r9a6rAhGclsLWkBysfmtr6Q kind;
union{
NimStringDesc* term;
NIM_CHAR ch;
NU8* charChoice;
tyObject_NonTerminalObj__VMn2tGRm8B9a9cqMEec3KPEA* nt;
NI index;
tySequence__5DSB9bTgCQCsIApS5TVlG8g* sons;
};
};

struct tySequence__5DSB9bTgCQCsIApS5TVlG8g : TGenericSeq {
  tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ data[SEQ_DECL_SIZE];
};

N_LIB_PRIVATE N_NIMCALL(void, peg__43AZ7ZFAo8xUltgm3ekenw)(NimStringDesc* pattern, tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ* Result);
static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
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, stdlib_pegsDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);

extern NIM_BOOL nimInErrorMode__759bT87luu8XGcbkw13FUjA;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;

static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size) {
	void* T1_ = memset(a, v, ((size_t) (size)));
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
	NIM_BOOL* result;
	result = (NIM_BOOL*)0;
	result = (&nimInErrorMode__759bT87luu8XGcbkw13FUjA);
	return result;
}
static N_INLINE(void, nimZeroMem)(void* p, NI size) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory(p, ((int) 0), size);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
}
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();
	stdlib_pegsDatInit000();
	(*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) {
{
	tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ T1_;
NIM_BOOL* nimErr_;
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
	nimZeroMem((void*)(&T1_), sizeof(tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ));
	peg__43AZ7ZFAo8xUltgm3ekenw(((NimStringDesc*) NIM_NIL), (&T1_));
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	(void)(T1_);
	BeforeRet_: ;
	nimTestErrorFlag();
	popFrame();
}
}

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("pegs")
    )
  ),
  nnkDiscardStmt.newTree(
    nnkCall.newTree(
      nnkDotExpr.newTree(
        newIdentNode("pegs"),
        newIdentNode("peg")
      ),
      newLit("")
    )
  )
)
1.2.0 :-1: FAIL

Output

Error: Command failed: nim cpp --gc:refc --exceptions:goto --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off  --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
Segmentation fault (core dumped)
Error: execution of an external program failed: '/home/runner/work/Nim/Nim/temp '

Stats

  • Created 2023-07-05T01:41:35Z
  • Started 2023-07-05T01:42:34
  • Finished 2023-07-05T01:42:35
  • Duration 1 minute
  • Commands nim cpp --gc:refc --exceptions:goto --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
  #  define nimfr_(proc, file) \
      TFrame FR_; \
      FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
  #  define nimfrs_(proc, file, slots, length) \
      struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename; NI len; VarSlot s[slots];} FR_; \
      FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
  #  define nimln_(n, file) \
      FR_.line = n; FR_.filename = file;
  struct NimStringDesc;
struct TGenericSeq;
struct tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ;
struct tyObject_NonTerminalObj__VMn2tGRm8B9a9cqMEec3KPEA;
struct tySequence__5DSB9bTgCQCsIApS5TVlG8g;
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc : public TGenericSeq {
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef NU8 tyEnum_PegKind__r9a6rAhGclsLWkBysfmtr6Q;
struct tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ {
tyEnum_PegKind__r9a6rAhGclsLWkBysfmtr6Q kind;
union{
NimStringDesc* term;
NIM_CHAR ch;
NU8* charChoice;
tyObject_NonTerminalObj__VMn2tGRm8B9a9cqMEec3KPEA* nt;
NI index;
tySequence__5DSB9bTgCQCsIApS5TVlG8g* sons;
};
};
struct tySequence__5DSB9bTgCQCsIApS5TVlG8g : TGenericSeq {
  tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ data[SEQ_DECL_SIZE];
};
N_LIB_PRIVATE N_NIMCALL(void, peg__43AZ7ZFAo8xUltgm3ekenw)(NimStringDesc* pattern, tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ* Result);
static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
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, stdlib_pegsDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
extern NIM_BOOL nimInErrorMode__759bT87luu8XGcbkw13FUjA;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size) {
	void* T1_ = memset(a, v, ((size_t) (size)));
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
	NIM_BOOL* result;
	result = (NIM_BOOL*)0;
	result = (&nimInErrorMode__759bT87luu8XGcbkw13FUjA);
	return result;
}
static N_INLINE(void, nimZeroMem)(void* p, NI size) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory(p, ((int) 0), size);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
}
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();
	stdlib_pegsDatInit000();
	(*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) {
{
	tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ T1_;
NIM_BOOL* nimErr_;
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
	nimZeroMem((void*)(&T1_), sizeof(tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ));
	peg__43AZ7ZFAo8xUltgm3ekenw(((NimStringDesc*) NIM_NIL), (&T1_));
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	(void)(T1_);
	BeforeRet_: ;
	nimTestErrorFlag();
	popFrame();
}
}

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("pegs")
    )
  ),
  nnkDiscardStmt.newTree(
    nnkCall.newTree(
      nnkDotExpr.newTree(
        newIdentNode("pegs"),
        newIdentNode("peg")
      ),
      newLit("")
    )
  )
)
1.0.0 :-1: FAIL

Output

Error: Command failed: nim cpp --gc:refc --exceptions:goto --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off  --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
command line(1, 2) Error: invalid command line option: '--exceptions'

Stats

  • Created 2023-07-05T01:41:35Z
  • Started 2023-07-05T01:42:48
  • Finished 2023-07-05T01:42:48
  • Duration now
  • Commands nim cpp --gc:refc --exceptions:goto --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
  #  define nimfr_(proc, file) \
      TFrame FR_; \
      FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
  #  define nimfrs_(proc, file, slots, length) \
      struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename; NI len; VarSlot s[slots];} FR_; \
      FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
  #  define nimln_(n, file) \
      FR_.line = n; FR_.filename = file;
  struct NimStringDesc;
struct TGenericSeq;
struct tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ;
struct tyObject_NonTerminalObj__VMn2tGRm8B9a9cqMEec3KPEA;
struct tySequence__5DSB9bTgCQCsIApS5TVlG8g;
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc : public TGenericSeq {
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef NU8 tyEnum_PegKind__r9a6rAhGclsLWkBysfmtr6Q;
struct tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ {
tyEnum_PegKind__r9a6rAhGclsLWkBysfmtr6Q kind;
union{
NimStringDesc* term;
NIM_CHAR ch;
NU8* charChoice;
tyObject_NonTerminalObj__VMn2tGRm8B9a9cqMEec3KPEA* nt;
NI index;
tySequence__5DSB9bTgCQCsIApS5TVlG8g* sons;
};
};
struct tySequence__5DSB9bTgCQCsIApS5TVlG8g : TGenericSeq {
  tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ data[SEQ_DECL_SIZE];
};
N_LIB_PRIVATE N_NIMCALL(void, peg__43AZ7ZFAo8xUltgm3ekenw)(NimStringDesc* pattern, tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ* Result);
static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
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, stdlib_pegsDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
extern NIM_BOOL nimInErrorMode__759bT87luu8XGcbkw13FUjA;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size) {
	void* T1_ = memset(a, v, ((size_t) (size)));
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
	NIM_BOOL* result;
	result = (NIM_BOOL*)0;
	result = (&nimInErrorMode__759bT87luu8XGcbkw13FUjA);
	return result;
}
static N_INLINE(void, nimZeroMem)(void* p, NI size) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory(p, ((int) 0), size);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
}
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();
	stdlib_pegsDatInit000();
	(*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) {
{
	tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ T1_;
NIM_BOOL* nimErr_;
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
	nimZeroMem((void*)(&T1_), sizeof(tyObject_Peg__4Bytir9b2lq5I84yi5O7ztQ));
	peg__43AZ7ZFAo8xUltgm3ekenw(((NimStringDesc*) NIM_NIL), (&T1_));
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	(void)(T1_);
	BeforeRet_: ;
	nimTestErrorFlag();
	popFrame();
}
}

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("pegs")
    )
  ),
  nnkDiscardStmt.newTree(
    nnkCall.newTree(
      nnkDotExpr.newTree(
        newIdentNode("pegs"),
        newIdentNode("peg")
      ),
      newLit("")
    )
  )
)
??? ➡️ 🐛

Diagnostics

The commit that introduced the bug can not be found, but the bug is in the commits:

(Can not find the commit because Nim can not be re-built commit-by-commit to bisect).

🤖 Bug found in 11 minutes bisecting 9 commits at 1 commits per second.

@juancarlospaco
Copy link
Collaborator

@ringabout ARC bug, refc works, exception goto unrelated.

@ringabout
Copy link
Member

Well, it's related. With goto exception, cpp backend crashs.

@demotomohiro
Copy link
Contributor

I found another code that produce same error.

teststdin.nim:

import std/syncio

let l = stdin.readLine
echo l
$ nim cpp --exceptions:goto teststdin.nim 
CC: ../nim-2.1.1/lib/std/syncio.nim
/tmp/nimcache123/teststdin/debug/@m..@snim-2.1.1@slib@sstd@ssyncio.nim.cpp: In function 'void checkErr__stdZsyncio_u161(FILE*)'
:
/tmp/nimcache123/teststdin/debug/@m..@snim-2.1.1@slib@sstd@ssyncio.nim.cpp:291:25: error: jump to label 'LA6_'
  291 |                         LA6_:;
      |                         ^~~~
/tmp/nimcache123/teststdin/debug/@m..@snim-2.1.1@slib@sstd@ssyncio.nim.cpp:275:50: note:   from here
  275 |                 if (NIM_UNLIKELY(*nimErr_)) goto LA6_;
      |                                                  ^~~~
/tmp/nimcache123/teststdin/debug/@m..@snim-2.1.1@slib@sstd@ssyncio.nim.cpp:276:26: note:   crosses initialization of 'char* T8
'
  276 |                 NCSTRING T8_ = strerror(errno);
      |                          ^~~

gcc version 13.2.1 20230826 (Gentoo 13.2.1_p20230826 p7)

$ nim -v
Nim Compiler Version 2.1.1 [Linux: amd64]
Compiled at 2023-11-28
Copyright (c) 2006-2023 by Andreas Rumpf

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

Araq pushed a commit that referenced this issue Dec 12, 2024
…s invalid C++ (#24531)

fixes #22101

The old implementation generates

`auto T = value;` for the cpp backend which causes problems for goto
exceptions. This PR puts the declaration of `T` to the cpsLocals parts
and makes it compatible with goto exceptions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants