nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.59k stars 1.47k forks source link

{.compileTime.} on a function with forward declaration, called before the function's body is defined, causes the function to silently fail, returning an empty string. #21352

Open Ntsekees opened 1 year ago

Ntsekees commented 1 year ago

Description

{.compileTime.} on a function with forward declaration, called before the function's body is defined, causes the function to silently fail, returning an empty string. (Nim compiler v1.6.10 [Linux: amd64].) The demonstration code below should suffice for depicting the issue:

# Compile time, defined in advance
func function_ct(s: string): string {.compileTime.} =
  return s

# Run time, defined in advance
func function_rt(s: string): string =
  return s

# Compile time, forward declaration
func function_fct(s: string): string {.compileTime.}

# Run time, forward declaration
func function_frt(s: string): string

const CT = function_ct("abcd")   # OK
const RT = function_rt("abcd")   # OK
const FCT = function_fct("abcd") # FAIL: EMPTY STRING
let   FRT = function_frt("abcd") # OK
# ↑ ⟪const⟫ cannot be used instead of ⟪let⟫ for that last one, I don't know whether that's intentional or not.

echo "⟪" & CT & "⟫"      # ⟪abcd⟫ → OK
echo "⟪" & RT & "⟫"      # ⟪abcd⟫ → OK
echo "⟪" & FCT & "⟫"     # ⟪⟫     → FAIL: EMPTY STRING
echo "⟪" & FRT & "⟫"     # ⟪abcd⟫ → OK

func function_fct(s: string): string {.compileTime.} =
  return s

func function_frt(s: string): string =
  return s

In this code, we define 4 dummy functions: • two of them are tagged with the {.compileTime.} pragma, the two others aren't (and run at runtime). • two of them are forward declared (with their body defined below the call site), the two others are fully defined above their call site.

Constatations: Of the four functions, the two that are defined (body included) above the call site work seamlessly. The forward-declared runtime function doesn't work with the const keyword, but that may be intentional (let works however). The forward-declared function tagged with {.compileTime.} fails and return an empty string, instead of the expected abcd string, which all the three other functions return.

It seems that the compiler fails to fetch (or otherwise execute properly) the body of that compileTime function; it is odd that it doesn't cause a crash or an error and that an actual dummy value (an empty string) is returned, letting the program run successfully.

Nim Version

Nim Compiler Version 1.6.10 [Linux: amd64] Compiled at 2022-11-21 Copyright (c) 2006-2021 by Andreas Rumpf

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

Current Output

⟪abcd⟫
⟪abcd⟫
⟪⟫
⟪abcd⟫

Expected Output

⟪abcd⟫
⟪abcd⟫
⟪abcd⟫
⟪abcd⟫

Possible Solution

No response

Additional Information

I have only tested the test code on a single version of Nim, and on a single OS/architecture.

juancarlospaco commented 1 year ago

!nim c

func f(s: string): string {.compileTime.}
const FCT = f("abcd")
doAssert FCT == "abcd", FCT
func f(s: string): string {.compileTime.} = s
github-actions[bot] commented 1 year ago

@juancarlospaco (contributor)

devel :-1: FAIL

Output

Error: Command failed: nim c --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-#devel/lib/std/assertions.nim failedAssertImpl
/home/runner/.choosenim/toolchains/nim-#devel/lib/std/assertions.nim raiseAssert
/home/runner/.choosenim/toolchains/nim-#devel/lib/system/fatal.nim sysFatal
Error: unhandled exception: /home/runner/work/Nim/Nim/temp.nim(3, 1) `FCT == "abcd"`  [AssertionDefect]
Error: execution of an external program failed: '/home/runner/work/Nim/Nim/temp'

Stats

  • Created 2023-07-09T14:32:39Z
  • Started 2023-07-09T14:33:17
  • Finished 2023-07-09T14:33:19
  • Duration 1 minute
  • Commands nim c --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

```cpp #define NIM_INTBITS 64 #include "nimbase.h" #undef LANGUAGE_C #undef MIPSEB #undef MIPSEL #undef PPC #undef R3000 #undef R4000 #undef i386 #undef linux #undef mips #undef near #undef far #undef powerpc #undef unix #define nimfr_(proc, file) \ TFrame FR_; \ FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_); #define nimfrs_(proc, file, slots, length) \ struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename;NI len;VarSlot s[slots];} FR_; \ FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_); #define nimln_(n) \ FR_.line = n; #define nimlf_(n, file) \ FR_.line = n; FR_.filename = file; typedef struct NimStrPayload NimStrPayload; typedef struct NimStringV2 NimStringV2; struct NimStrPayload { NI cap; NIM_CHAR data[SEQ_DECL_SIZE]; }; struct NimStringV2 { NI len; NimStrPayload* p; }; N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__stdZassertions_u310)(NimStringV2 msg_p0); static N_INLINE(NIM_BOOL*, nimErrorFlag)(void); N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void); static N_INLINE(void, nimFrame)(TFrame* s_p0); N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4483)(void); static N_INLINE(void, popFrame)(void); N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystemdotnim_Init000)(void); N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void); static const struct { NI cap; NIM_CHAR data[57+1]; } TM__SRd76hP9cMfCzdUO857UhQQ_2 = { 57 | NIM_STRLIT_FLAG, "/home/runner/work/Nim/Nim/temp.nim(3, 1) `FCT == \"abcd\"` " }; static const NimStringV2 TM__SRd76hP9cMfCzdUO857UhQQ_3 = {57, (NimStrPayload*)&TM__SRd76hP9cMfCzdUO857UhQQ_2}; extern NIM_BOOL nimInErrorMode__system_u4265; extern TFrame* framePtr__system_u3877; static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) { NIM_BOOL* result; result = (NIM_BOOL*)0; result = (&nimInErrorMode__system_u4265); return result; } static N_INLINE(void, nimFrame)(TFrame* s_p0) { { if (!(framePtr__system_u3877 == ((TFrame*) NIM_NIL))) goto LA3_; (*s_p0).calldepth = ((NI16)0); } goto LA1_; LA3_: ; { (*s_p0).calldepth = (NI16)((*framePtr__system_u3877).calldepth + ((NI16)1)); } LA1_: ; (*s_p0).prev = framePtr__system_u3877; framePtr__system_u3877 = s_p0; { if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_; callDepthLimitReached__system_u4483(); } LA8_: ; } static N_INLINE(void, popFrame)(void) { framePtr__system_u3877 = (*framePtr__system_u3877).prev; } N_LIB_PRIVATE void PreMainInner(void) { } N_LIB_PRIVATE int cmdCount; N_LIB_PRIVATE char** cmdLine; N_LIB_PRIVATE char** gEnv; N_LIB_PRIVATE void PreMain(void) { #if 0 void (*volatile inner)(void); inner = PreMainInner; atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystemdotnim_Init000(); (*inner)(); #else atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystemdotnim_Init000(); PreMainInner(); #endif } N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) { NimMainModule(); } N_CDECL(void, NimMain)(void) { #if 0 void (*volatile inner)(void); PreMain(); inner = NimMainInner; (*inner)(); #else PreMain(); NimMainInner(); #endif } int main(int argc, char** args, char** env) { cmdLine = args; cmdCount = argc; gEnv = env; NimMain(); return nim_program_result; } N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) { { NIM_BOOL* nimErr_; nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim"); nimErr_ = nimErrorFlag(); { if (!NIM_TRUE) goto LA3_; failedAssertImpl__stdZassertions_u310(TM__SRd76hP9cMfCzdUO857UhQQ_3); if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_; } LA3_: ; BeforeRet_: ; nimTestErrorFlag(); popFrame(); } } ```

AST

```nim nnkStmtList.newTree( nnkFuncDef.newTree( newIdentNode("f"), newEmptyNode(), newEmptyNode(), nnkFormalParams.newTree( newIdentNode("string"), nnkIdentDefs.newTree( newIdentNode("s"), newIdentNode("string"), newEmptyNode() ) ), nnkPragma.newTree( newIdentNode("compileTime") ), newEmptyNode(), newEmptyNode() ), nnkConstSection.newTree( nnkConstDef.newTree( newIdentNode("FCT"), newEmptyNode(), nnkCall.newTree( newIdentNode("f"), newLit("abcd") ) ) ), nnkCommand.newTree( newIdentNode("doAssert"), nnkInfix.newTree( newIdentNode("=="), newIdentNode("FCT"), newLit("abcd") ), newIdentNode("FCT") ), nnkFuncDef.newTree( newIdentNode("f"), newEmptyNode(), newEmptyNode(), nnkFormalParams.newTree( newIdentNode("string"), nnkIdentDefs.newTree( newIdentNode("s"), newIdentNode("string"), newEmptyNode() ) ), nnkPragma.newTree( newIdentNode("compileTime") ), newEmptyNode(), nnkStmtList.newTree( newIdentNode("s") ) ) ) ```
stable :-1: FAIL

Output

Error: Command failed: nim c --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/system/assertions.nim failedAssertImpl
/home/runner/.choosenim/toolchains/nim-1.6.14/lib/system/assertions.nim raiseAssert
/home/runner/.choosenim/toolchains/nim-1.6.14/lib/system/fatal.nim sysFatal
Error: unhandled exception: /home/runner/work/Nim/Nim/temp.nim(3, 10) `FCT == "abcd"`  [AssertionDefect]
Error: execution of an external program failed: '/home/runner/work/Nim/Nim/temp '

Stats

  • Created 2023-07-09T14:32:39Z
  • Started 2023-07-09T14:33:19
  • Finished 2023-07-09T14:33:20
  • Duration 1 minute
  • Commands nim c --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

```cpp #define NIM_INTBITS 64 #include "nimbase.h" #undef LANGUAGE_C #undef MIPSEB #undef MIPSEL #undef PPC #undef R3000 #undef R4000 #undef i386 #undef linux #undef mips #undef near #undef far #undef powerpc #undef unix # define nimfr_(proc, file) \ TFrame FR_; \ FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_); # define nimfrs_(proc, file, slots, length) \ struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename; NI len; VarSlot s[slots];} FR_; \ FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_); # define nimln_(n, file) \ FR_.line = n; FR_.filename = file; typedef struct NimStringDesc NimStringDesc; typedef struct TGenericSeq TGenericSeq; struct TGenericSeq { NI len; NI reserved; }; struct NimStringDesc { TGenericSeq Sup; NIM_CHAR data[SEQ_DECL_SIZE]; }; N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__systemZassertions_56)(NimStringDesc* msg); 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_2997)(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, NimMainModule)(void); STRING_LITERAL(TM__SRd76hP9cMfCzdUO857UhQQ_2, "/home/runner/work/Nim/Nim/temp.nim(3, 10) `FCT == \"abcd\"` ", 58); 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_2997(); } 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; atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_DatInit000(); initStackBottomWith((void *)&inner); atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus1dot6dot14atslibatssystemdotnim_Init000(); (*inner)(); } N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) { NimMainModule(); } N_CDECL(void, NimMain)(void) { void (*volatile inner)(void); PreMain(); inner = NimMainInner; initStackBottomWith((void *)&inner); (*inner)(); } int main(int argc, char** args, char** env) { cmdLine = args; cmdCount = argc; gEnv = env; NimMain(); return nim_program_result; } N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) { { nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim"); { if (!NIM_TRUE) goto LA3_; failedAssertImpl__systemZassertions_56(((NimStringDesc*) &TM__SRd76hP9cMfCzdUO857UhQQ_2)); } LA3_: ; popFrame(); } } ```

AST

```nim nnkStmtList.newTree( nnkFuncDef.newTree( newIdentNode("f"), newEmptyNode(), newEmptyNode(), nnkFormalParams.newTree( newIdentNode("string"), nnkIdentDefs.newTree( newIdentNode("s"), newIdentNode("string"), newEmptyNode() ) ), nnkPragma.newTree( newIdentNode("compileTime") ), newEmptyNode(), newEmptyNode() ), nnkConstSection.newTree( nnkConstDef.newTree( newIdentNode("FCT"), newEmptyNode(), nnkCall.newTree( newIdentNode("f"), newLit("abcd") ) ) ), nnkCommand.newTree( newIdentNode("doAssert"), nnkInfix.newTree( newIdentNode("=="), newIdentNode("FCT"), newLit("abcd") ), newIdentNode("FCT") ), nnkFuncDef.newTree( newIdentNode("f"), newEmptyNode(), newEmptyNode(), nnkFormalParams.newTree( newIdentNode("string"), nnkIdentDefs.newTree( newIdentNode("s"), newIdentNode("string"), newEmptyNode() ) ), nnkPragma.newTree( newIdentNode("compileTime") ), newEmptyNode(), nnkStmtList.newTree( newIdentNode("s") ) ) ) ```
1.6.0 :-1: FAIL

Output

Error: Command failed: nim c --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/system/assertions.nim failedAssertImpl
/home/runner/.choosenim/toolchains/nim-1.6.0/lib/system/assertions.nim raiseAssert
/home/runner/.choosenim/toolchains/nim-1.6.0/lib/system/fatal.nim sysFatal
Error: unhandled exception: /home/runner/work/Nim/Nim/temp.nim(3, 10) `FCT == "abcd"`  [AssertionDefect]
Error: execution of an external program failed: '/home/runner/work/Nim/Nim/temp '

Stats

  • Created 2023-07-09T14:32:39Z
  • Started 2023-07-09T14:33:24
  • Finished 2023-07-09T14:33:25
  • Duration 1 minute
  • Commands nim c --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

```cpp #define NIM_INTBITS 64 #include "nimbase.h" #undef LANGUAGE_C #undef MIPSEB #undef MIPSEL #undef PPC #undef R3000 #undef R4000 #undef i386 #undef linux #undef mips #undef near #undef far #undef powerpc #undef unix # define nimfr_(proc, file) \ TFrame FR_; \ FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_); # define nimfrs_(proc, file, slots, length) \ struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename; NI len; VarSlot s[slots];} FR_; \ FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_); # define nimln_(n, file) \ FR_.line = n; FR_.filename = file; typedef struct NimStringDesc NimStringDesc; typedef struct TGenericSeq TGenericSeq; struct TGenericSeq { NI len; NI reserved; }; struct NimStringDesc { TGenericSeq Sup; NIM_CHAR data[SEQ_DECL_SIZE]; }; N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl_systemZassertions_56)(NimStringDesc* msg); 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_2997)(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); STRING_LITERAL(TM__SRd76hP9cMfCzdUO857UhQQ_2, "/home/runner/work/Nim/Nim/temp.nim(3, 10) `FCT == \"abcd\"` ", 58); 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_2997(); } 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) { { nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim"); { if (!NIM_TRUE) goto LA3_; failedAssertImpl_systemZassertions_56(((NimStringDesc*) &TM__SRd76hP9cMfCzdUO857UhQQ_2)); } LA3_: ; popFrame(); } } ```

AST

```nim nnkStmtList.newTree( nnkFuncDef.newTree( newIdentNode("f"), newEmptyNode(), newEmptyNode(), nnkFormalParams.newTree( newIdentNode("string"), nnkIdentDefs.newTree( newIdentNode("s"), newIdentNode("string"), newEmptyNode() ) ), nnkPragma.newTree( newIdentNode("compileTime") ), newEmptyNode(), newEmptyNode() ), nnkConstSection.newTree( nnkConstDef.newTree( newIdentNode("FCT"), newEmptyNode(), nnkCall.newTree( newIdentNode("f"), newLit("abcd") ) ) ), nnkCommand.newTree( newIdentNode("doAssert"), nnkInfix.newTree( newIdentNode("=="), newIdentNode("FCT"), newLit("abcd") ), newIdentNode("FCT") ), nnkFuncDef.newTree( newIdentNode("f"), newEmptyNode(), newEmptyNode(), nnkFormalParams.newTree( newIdentNode("string"), nnkIdentDefs.newTree( newIdentNode("s"), newIdentNode("string"), newEmptyNode() ) ), nnkPragma.newTree( newIdentNode("compileTime") ), newEmptyNode(), nnkStmtList.newTree( newIdentNode("s") ) ) ) ```
1.4.0 :-1: FAIL

Output

Error: Command failed: nim c --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/system/assertions.nim failedAssertImpl
/home/runner/.choosenim/toolchains/nim-1.4.0/lib/system/assertions.nim raiseAssert
/home/runner/.choosenim/toolchains/nim-1.4.0/lib/system/fatal.nim sysFatal
Error: unhandled exception: /home/runner/work/Nim/Nim/temp.nim(3, 10) `FCT == "abcd"`  [AssertionDefect]
Error: execution of an external program failed: '/home/runner/work/Nim/Nim/temp '

Stats

  • Created 2023-07-09T14:32:39Z
  • Started 2023-07-09T14:33:29
  • Finished 2023-07-09T14:33:30
  • Duration 1 minute
  • Commands nim c --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

```cpp #define NIM_INTBITS 64 #include "nimbase.h" #undef LANGUAGE_C #undef MIPSEB #undef MIPSEL #undef PPC #undef R3000 #undef R4000 #undef i386 #undef linux #undef mips #undef near #undef far #undef powerpc #undef unix # define nimfr_(proc, file) \ TFrame FR_; \ FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_); # define nimfrs_(proc, file, slots, length) \ struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename; NI len; VarSlot s[slots];} FR_; \ FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_); # define nimln_(n, file) \ FR_.line = n; FR_.filename = file; typedef struct NimStringDesc NimStringDesc; typedef struct TGenericSeq TGenericSeq; struct TGenericSeq { NI len; NI reserved; }; struct NimStringDesc { TGenericSeq Sup; NIM_CHAR data[SEQ_DECL_SIZE]; }; N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__W9cjVocn1tjhW7p7xohJj6A)(NimStringDesc* msg); 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); STRING_LITERAL(TM__SRd76hP9cMfCzdUO857UhQQ_2, "/home/runner/work/Nim/Nim/temp.nim(3, 10) `FCT == \"abcd\"` ", 58); 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) { { nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim"); { if (!NIM_TRUE) goto LA3_; failedAssertImpl__W9cjVocn1tjhW7p7xohJj6A(((NimStringDesc*) &TM__SRd76hP9cMfCzdUO857UhQQ_2)); } LA3_: ; popFrame(); } } ```

AST

```nim nnkStmtList.newTree( nnkFuncDef.newTree( newIdentNode("f"), newEmptyNode(), newEmptyNode(), nnkFormalParams.newTree( newIdentNode("string"), nnkIdentDefs.newTree( newIdentNode("s"), newIdentNode("string"), newEmptyNode() ) ), nnkPragma.newTree( newIdentNode("compileTime") ), newEmptyNode(), newEmptyNode() ), nnkConstSection.newTree( nnkConstDef.newTree( newIdentNode("FCT"), newEmptyNode(), nnkCall.newTree( newIdentNode("f"), newLit("abcd") ) ) ), nnkCommand.newTree( newIdentNode("doAssert"), nnkInfix.newTree( newIdentNode("=="), newIdentNode("FCT"), newLit("abcd") ), newIdentNode("FCT") ), nnkFuncDef.newTree( newIdentNode("f"), newEmptyNode(), newEmptyNode(), nnkFormalParams.newTree( newIdentNode("string"), nnkIdentDefs.newTree( newIdentNode("s"), newIdentNode("string"), newEmptyNode() ) ), nnkPragma.newTree( newIdentNode("compileTime") ), newEmptyNode(), nnkStmtList.newTree( newIdentNode("s") ) ) ) ```
1.2.0 :-1: FAIL

Output

Error: Command failed: nim c --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/system/assertions.nim failedAssertImpl
/home/runner/.choosenim/toolchains/nim-1.2.0/lib/system/assertions.nim raiseAssert
/home/runner/.choosenim/toolchains/nim-1.2.0/lib/system/fatal.nim sysFatal
Error: unhandled exception: /home/runner/work/Nim/Nim/temp.nim(3, 10) `FCT == "abcd"`  [AssertionError]
Error: execution of an external program failed: '/home/runner/work/Nim/Nim/temp '

Stats

  • Created 2023-07-09T14:32:39Z
  • Started 2023-07-09T14:33:46
  • Finished 2023-07-09T14:33:47
  • Duration 1 minute
  • Commands nim c --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

```cpp #define NIM_INTBITS 64 #include "nimbase.h" #undef LANGUAGE_C #undef MIPSEB #undef MIPSEL #undef PPC #undef R3000 #undef R4000 #undef i386 #undef linux #undef mips #undef near #undef far #undef powerpc #undef unix # define nimfr_(proc, file) \ TFrame FR_; \ FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_); # define nimfrs_(proc, file, slots, length) \ struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename; NI len; VarSlot s[slots];} FR_; \ FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_); # define nimln_(n, file) \ FR_.line = n; FR_.filename = file; typedef struct NimStringDesc NimStringDesc; typedef struct TGenericSeq TGenericSeq; struct TGenericSeq { NI len; NI reserved; }; struct NimStringDesc { TGenericSeq Sup; NIM_CHAR data[SEQ_DECL_SIZE]; }; N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__W9cjVocn1tjhW7p7xohJj6A)(NimStringDesc* msg); 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); STRING_LITERAL(TM__SRd76hP9cMfCzdUO857UhQQ_2, "/home/runner/work/Nim/Nim/temp.nim(3, 10) `FCT == \"abcd\"` ", 58); 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) { { nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim"); { if (!NIM_TRUE) goto LA3_; failedAssertImpl__W9cjVocn1tjhW7p7xohJj6A(((NimStringDesc*) &TM__SRd76hP9cMfCzdUO857UhQQ_2)); } LA3_: ; popFrame(); } } ```

AST

```nim nnkStmtList.newTree( nnkFuncDef.newTree( newIdentNode("f"), newEmptyNode(), newEmptyNode(), nnkFormalParams.newTree( newIdentNode("string"), nnkIdentDefs.newTree( newIdentNode("s"), newIdentNode("string"), newEmptyNode() ) ), nnkPragma.newTree( newIdentNode("compileTime") ), newEmptyNode(), newEmptyNode() ), nnkConstSection.newTree( nnkConstDef.newTree( newIdentNode("FCT"), newEmptyNode(), nnkCall.newTree( newIdentNode("f"), newLit("abcd") ) ) ), nnkCommand.newTree( newIdentNode("doAssert"), nnkInfix.newTree( newIdentNode("=="), newIdentNode("FCT"), newLit("abcd") ), newIdentNode("FCT") ), nnkFuncDef.newTree( newIdentNode("f"), newEmptyNode(), newEmptyNode(), nnkFormalParams.newTree( newIdentNode("string"), nnkIdentDefs.newTree( newIdentNode("s"), newIdentNode("string"), newEmptyNode() ) ), nnkPragma.newTree( newIdentNode("compileTime") ), newEmptyNode(), nnkStmtList.newTree( newIdentNode("s") ) ) ) ```
1.0.0 :-1: FAIL

Output

Error: Command failed: nim c --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.0.0/lib/system/assertions.nim failedAssertImpl
/home/runner/.choosenim/toolchains/nim-1.0.0/lib/system/assertions.nim raiseAssert
/home/runner/.choosenim/toolchains/nim-1.0.0/lib/system/fatal.nim sysFatal
Error: unhandled exception: /home/runner/work/Nim/Nim/temp.nim(3, 10) `FCT == "abcd"`  [AssertionError]
Error: execution of an external program failed: '/home/runner/work/Nim/Nim/temp '

Stats

  • Created 2023-07-09T14:32:39Z
  • Started 2023-07-09T14:34:01
  • Finished 2023-07-09T14:34:02
  • Duration 1 minute
  • Commands nim c --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

```cpp #define NIM_INTBITS 64 #include "nimbase.h" #undef LANGUAGE_C #undef MIPSEB #undef MIPSEL #undef PPC #undef R3000 #undef R4000 #undef i386 #undef linux #undef mips #undef near #undef far #undef powerpc #undef unix # define nimfr_(proc, file) \ TFrame FR_; \ FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_); # define nimfrs_(proc, file, slots, length) \ struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename; NI len; VarSlot s[slots];} FR_; \ FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_); # define nimln_(n, file) \ FR_.line = n; FR_.filename = file; typedef struct NimStringDesc NimStringDesc; typedef struct TGenericSeq TGenericSeq; struct TGenericSeq { NI len; NI reserved; }; struct NimStringDesc { TGenericSeq Sup; NIM_CHAR data[SEQ_DECL_SIZE]; }; N_LIB_PRIVATE N_NIMCALL(void, failedAssertImpl__W9cjVocn1tjhW7p7xohJj6A)(NimStringDesc* msg); 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); extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw; STRING_LITERAL(TM__SRd76hP9cMfCzdUO857UhQQ_2, "/home/runner/work/Nim/Nim/temp.nim(3, 10) `FCT == \"abcd\"` ", 58); 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) { { nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim"); { if (!NIM_TRUE) goto LA3_; failedAssertImpl__W9cjVocn1tjhW7p7xohJj6A(((NimStringDesc*) &TM__SRd76hP9cMfCzdUO857UhQQ_2)); } LA3_: ; popFrame(); } } ```

AST

```nim nnkStmtList.newTree( nnkFuncDef.newTree( newIdentNode("f"), newEmptyNode(), newEmptyNode(), nnkFormalParams.newTree( newIdentNode("string"), nnkIdentDefs.newTree( newIdentNode("s"), newIdentNode("string"), newEmptyNode() ) ), nnkPragma.newTree( newIdentNode("compileTime") ), newEmptyNode(), newEmptyNode() ), nnkConstSection.newTree( nnkConstDef.newTree( newIdentNode("FCT"), newEmptyNode(), nnkCall.newTree( newIdentNode("f"), newLit("abcd") ) ) ), nnkCommand.newTree( newIdentNode("doAssert"), nnkInfix.newTree( newIdentNode("=="), newIdentNode("FCT"), newLit("abcd") ), newIdentNode("FCT") ), nnkFuncDef.newTree( newIdentNode("f"), newEmptyNode(), newEmptyNode(), nnkFormalParams.newTree( newIdentNode("string"), nnkIdentDefs.newTree( newIdentNode("s"), newIdentNode("string"), newEmptyNode() ) ), nnkPragma.newTree( newIdentNode("compileTime") ), newEmptyNode(), nnkStmtList.newTree( newIdentNode("s") ) ) ) ```
:robot: Bug found in 49 minutes bisecting 6 commits at 0 commits per second.