Skip to content

strformat issue with --gc:arc #13622

Closed
Closed
@genotrance

Description

@genotrance

Tried quite a bit to create a minimal version but was not able to recreate issue so sharing original.

Steps:

git clone https://github.com/genotrance/nimterop
cd nimterop
nimble install -d
nim c --gc:arc nimterop/toast

Error:

/home/gt/.cache/nim/toast_d/@mast.nim.c: In function ‘searchAstForNode__LCeIkDCyQ9b5OtwCCJHeafA’:
/home/gt/.cache/nim/toast_d/@mast.nim.c:1744:14: error: redeclaration of ‘fmtRes’ with no linkage
  NimStringV2 fmtRes;
              ^~~~~~
/home/gt/.cache/nim/toast_d/@mast.nim.c:1740:14: note: previous declaration of ‘fmtRes’ was here
  NimStringV2 fmtRes;
              ^~~~~~
/home/gt/.cache/nim/toast_d/@mast.nim.c: In function ‘printNim__DtB2g4OGgDcYPI5HzrJ2tg’:
/home/gt/.cache/nim/toast_d/@mast.nim.c:2642:14: error: redeclaration of ‘fmtRes_2’ with no linkage
  NimStringV2 fmtRes_2;
              ^~~~~~~~
/home/gt/.cache/nim/toast_d/@mast.nim.c:2641:14: note: previous declaration of ‘fmtRes_2’ was here
  NimStringV2 fmtRes_2;
              ^~~~~~~~
/home/gt/.cache/nim/toast_d/@mast.nim.c:2646:14: error: redeclaration of ‘fmtRes_3’ with no linkage
  NimStringV2 fmtRes_3;
              ^~~~~~~~
/home/gt/.cache/nim/toast_d/@mast.nim.c:2645:14: note: previous declaration of ‘fmtRes_3’ was here
  NimStringV2 fmtRes_3;
              ^~~~~~~~
/home/gt/.cache/nim/toast_d/@mast.nim.c:2651:14: error: redeclaration of ‘fmtRes_4’ with no linkage
  NimStringV2 fmtRes_4;
              ^~~~~~~~
/home/gt/.cache/nim/toast_d/@mast.nim.c:2648:14: note: previous declaration of ‘fmtRes_4’ was here
  NimStringV2 fmtRes_4;
              ^~~~~~~~
/home/gt/.cache/nim/toast_d/@mast.nim.c:2657:14: error: redeclaration of ‘fmtRes_5’ with no linkage
  NimStringV2 fmtRes_5;
              ^~~~~~~~
/home/gt/.cache/nim/toast_d/@mast.nim.c:2656:14: note: previous declaration of ‘fmtRes_5’ was here
  NimStringV2 fmtRes_5;
              ^~~~~~~~
/home/gt/.cache/nim/toast_d/@mast.nim.c:2661:14: error: redeclaration of ‘fmtRes_6’ with no linkage
  NimStringV2 fmtRes_6;
              ^~~~~~~~
/home/gt/.cache/nim/toast_d/@mast.nim.c:2660:14: note: previous declaration of ‘fmtRes_6’ was here
  NimStringV2 fmtRes_6;
              ^~~~~~~~
/home/gt/.cache/nim/toast_d/@mast.nim.c:2669:14: error: redeclaration of ‘fmtRes_8’ with no linkage
  NimStringV2 fmtRes_8;
              ^~~~~~~~
/home/gt/.cache/nim/toast_d/@mast.nim.c:2668:14: note: previous declaration of ‘fmtRes_8’ was here
  NimStringV2 fmtRes_8;
              ^~~~~~~~
Error: execution of an external compiler program 'gcc -c  -w -std=c11 -DUTF8PROC_STATIC -I/home/gt/.cache/nim/nimterop/nimterop/treesitter/lib/include -I/home/gt/.cache/nim/nimterop/nimterop/treesitter/lib/src -I/home/gt/.cache/nim/nimterop/nimterop/utf8proc -I/home/gt/.cache/nim/nimterop/nimterop/treesitter_c/src -I/home/gt/.cache/nim/nimterop/nimterop/treesitter_cpp/src   -I/home/gt/programming/nimdevel/lib -I/home/gt/programming/nimterop/nimterop -o /home/gt/.cache/nim/toast_d/@mast.nim.c.o /home/gt/.cache/nim/toast_d/@mast.nim.c' failed with exit code: 1

Snippet of generated C code that causes the problem:

N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, searchAstForNode__LCeIkDCyQ9b5OtwCCJHeafA)(tyObject_Ast__rTIUXFXA02DUE5L9c0QyPHw* ast, TSNode node, tyObject_NimStatecolonObjectType___anZzyrsXs39aG32iZ7k0SaA* nimState) {
	NIM_BOOL result;
	NimStringV2 childNames;
	tySequence__sM4lkSb7zS6F7OVMvW9cffQ colontmpD_;
	tyObject_StatecolonObjectType___JIBkEH55obsifn28rnCfUA* gState;
	NimStringV2 colontmpD__2;
	NimStringV2 colontmpD__3;
	NimStringV2 colontmpD__4;
	NimStringV2 colontmpD__5;
	NimStringV2 colontmpD__6;
	tyObject_Ast__rTIUXFXA02DUE5L9c0QyPHw* astChild;
	NimStringV2 colontmpD__7;
	tyObject_StatecolonObjectType___JIBkEH55obsifn28rnCfUA* gState_2;
	NimStringV2 colontmpD__8;
	NimStringV2 fmtRes;                                                        <=====
	NimStringV2 colontmpD__9;
	NimStringV2 colontmpD__10;
	NimStringV2 colontmpD__11;
	NimStringV2 fmtRes;                                                        <=====
	NimStringV2 colontmpD__12;
	NimStringV2 colontmpD__13;
	NimStringV2 colontmpD__14;

Code in question is line 114.

https://github.com/nimterop/nimterop/blob/a7aa69f71df6cacf6b4923c1f16c4a0aa8c47d7b/nimterop/ast.nim#L107-L121

strformat is the only one generating a fmtRes symbol.

Same code works fine without --gc:arc.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions