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

Duplicate definition in cpp codegen #6986

Closed
RedBeard0531 opened this Issue Dec 29, 2017 · 4 comments

Comments

Projects
None yet
5 participants
@RedBeard0531
Copy link
Contributor

RedBeard0531 commented Dec 29, 2017

import sequtils
import strutils


let rules = toSeq(lines("input"))
  .mapIt(it.split(" => ").mapIt(it.replace("/", "")))
  .mapIt((it[0], it[1]))
> nim cpp -d:release a21
Hint: used config file '/home/mstearn/nim/nim/config/nim.cfg' [Conf]
Hint: system [Processing]
Hint: a21 [Processing]
Hint: sequtils [Processing]
Hint: macros [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: math [Processing]
Hint: algorithm [Processing]
a21.nim(5, 5) Hint: 'rules' is declared but not used [XDeclaredButNotUsed]
CC: a21
CC: stdlib_system
CC: stdlib_sequtils
CC: stdlib_macros
CC: stdlib_strutils
CC: stdlib_parseutils
CC: stdlib_math
CC: stdlib_algorithm
Error: execution of an external compiler program 'g++ -c  -w -w -fpermissive -O3 -fno-strict-aliasing  -I/home/mstearn/nim/nim/lib -o /home/mstearn/aoc/21/nimcache/a21.o /home/mstearn/aoc/21/nimcache/a21.cpp' failed with exit code: 1

/home/mstearn/aoc/21/nimcache/a21.cpp:334:37: error: redefinition of ‘tySequence_sM4lkSb7zS6F7OVMvW9cffQ* result_Cbjk47dTBQHwrAZxXLxZZw_4’
 tySequence_sM4lkSb7zS6F7OVMvW9cffQ* result_Cbjk47dTBQHwrAZxXLxZZw_4;
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/mstearn/aoc/21/nimcache/a21.cpp:321:37: note: ‘tySequence_sM4lkSb7zS6F7OVMvW9cffQ* result_Cbjk47dTBQHwrAZxXLxZZw_4’ previously declared here
 tySequence_sM4lkSb7zS6F7OVMvW9cffQ* result_Cbjk47dTBQHwrAZxXLxZZw_4;
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/mstearn/aoc/21/nimcache/a21.cpp:335:16: error: redefinition of ‘NimStringDesc* x_D0OZ9aNVprOmety7qyz6CxQ_2’
 NimStringDesc* x_D0OZ9aNVprOmety7qyz6CxQ_2;
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/mstearn/aoc/21/nimcache/a21.cpp:322:16: note: ‘NimStringDesc* x_D0OZ9aNVprOmety7qyz6CxQ_2’ previously declared here
 NimStringDesc* x_D0OZ9aNVprOmety7qyz6CxQ_2;
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/mstearn/aoc/21/nimcache/a21.cpp:336:16: error: redefinition of ‘NimStringDesc* it_4in0LN2NNJ9bsya8DN5gD8A’
 NimStringDesc* it_4in0LN2NNJ9bsya8DN5gD8A;
                ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/mstearn/aoc/21/nimcache/a21.cpp:323:16: note: ‘NimStringDesc* it_4in0LN2NNJ9bsya8DN5gD8A’ previously declared here
 NimStringDesc* it_4in0LN2NNJ9bsya8DN5gD8A;
                ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/mstearn/aoc/21/nimcache/a21.cpp:340:16: error: redefinition of ‘NimStringDesc* it_4in0LN2NNJ9bsya8DN5gD8A_2’
 NimStringDesc* it_4in0LN2NNJ9bsya8DN5gD8A_2;
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/mstearn/aoc/21/nimcache/a21.cpp:327:16: note: ‘NimStringDesc* it_4in0LN2NNJ9bsya8DN5gD8A_2’ previously declared here
 NimStringDesc* it_4in0LN2NNJ9bsya8DN5gD8A_2;
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

Works fine with c codegen. This seems to be new in devel since it also works fine with 0.17.2

@cooldome

This comment has been minimized.

Copy link
Member

cooldome commented Feb 23, 2018

The issue is not that cpp specific. Small modification and it no longer compiles neither with C nor CPP backends:

import sequtils
import strutils
proc pp(s: string): auto =
   toSeq(lines(s)).mapIt(it.split(" => ").mapIt(it.replace("/", ""))).mapIt((it[0], it[1]))
echo pp("input")

Duplicate result symbols in generated C code. Tested latest to date Nim dev version

@Yardanico Yardanico added Codegen and removed C++ codegen labels Mar 15, 2018

skilchen added a commit to skilchen/Nim that referenced this issue Apr 5, 2018

Araq added a commit that referenced this issue Apr 6, 2018

@Yardanico Yardanico closed this Apr 6, 2018

@Yardanico Yardanico reopened this Apr 6, 2018

@Yardanico

This comment has been minimized.

Copy link
Collaborator

Yardanico commented Apr 6, 2018

Sorry, didn't check that fix was only for stdlib and not for codegen

@narimiran

This comment has been minimized.

Copy link
Member

narimiran commented Oct 13, 2018

Both the original example and @cooldome's modification compile without a problem in Nim 0.19.

Can this be closed?

@Araq

This comment has been minimized.

Copy link
Member

Araq commented Oct 13, 2018

Can this be closed?

Requires a test case.

@narimiran narimiran referenced this issue Oct 28, 2018

Merged

Closes #6986 #9541

@krux02 krux02 closed this in f4149ae Oct 29, 2018

krux02 added a commit that referenced this issue Oct 29, 2018

ianmcxa added a commit to ianmcxa/Nim that referenced this issue Oct 30, 2018

narimiran added a commit to narimiran/Nim that referenced this issue Oct 31, 2018

narimiran added a commit to narimiran/Nim that referenced this issue Nov 1, 2018

narimiran added a commit that referenced this issue Nov 1, 2018

narimiran added a commit that referenced this issue Nov 1, 2018

Closes #6986
(cherry picked from commit f4149ae)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment