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

C compiler error when using statement list expression with a template #15637

Open
ghost opened this issue Oct 19, 2020 · 1 comment
Open

C compiler error when using statement list expression with a template #15637

ghost opened this issue Oct 19, 2020 · 1 comment

Comments

@ghost
Copy link

ghost commented Oct 19, 2020

Couldn't think of a better title, code speaks for itself.
Found in https://github.com/nocturn9x/japl

Example

proc newString(data: int): int = 
  result = data

template addObject(s: int): untyped =
  discard s
  s

proc slice() =
  let obj = addObject(newString((var intval = 5; intval)))

slice()

Current Output

/home/dian/.cache/nim/a_d/@ma.nim.c: In functionslice__GUeAIxBAJ79bdeFn6EpeyzA’:
/home/dian/.cache/nim/a_d/@ma.nim.c:94:5: error: redeclaration ofintvalwith no linkage
   94 |  NI intval;
      |     ^~~~~~
/home/dian/.cache/nim/a_d/@ma.nim.c:92:5: note: previous declaration ofintvalwas here
   92 |  NI intval;
      |     ^~~~~~

Expected Output

Successful compilation?

Possible Solution

$ nim -v
Nim Compiler Version 1.5.1 [Linux: amd64]
Compiled at 2020-10-18
Copyright (c) 2006-2020 by Andreas Rumpf

git hash: 82adefa9d10485478456ff75a700d982471708d2
active boot switches: -d:release -d:danger
@ghost ghost added the Templates label Oct 19, 2020
@nocturn9x
Copy link

Glad to see I helped spotting a bug! Unfortunately my competence pretty much ends here though 😢

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

No branches or pull requests

2 participants