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

BUG: "varargs[string, `$`]" calls `$` n^2 times instead of n times (n=len(varargs)) #8316

Closed
timotheecour opened this issue Jul 14, 2018 · 1 comment

Comments

@timotheecour
Copy link
Contributor

commented Jul 14, 2018

(reduced from a more complex program)

proc myAppend[T](a:T):string=
  echo "a:", a
  return $a

template append2*(args: varargs[string, myAppend]): string =
  var ret:string
  for a in args:
    echo "ret:", ret
    ret.add(a)
  ret

let foo = append2("1", "2", "3")
echo foo

prints:

a:1
a:2
a:3
ret:
a:1
a:2
a:3
ret:1
a:1
a:2
a:3
ret:12
123

instead of:

a:1
a:2
a:3
ret:
ret:1
ret:12
123
@Araq

This comment has been minimized.

Copy link
Member

commented Jul 17, 2018

Lol that looks pretty bad.

@krux02 krux02 self-assigned this Apr 10, 2019

Araq added a commit that referenced this issue Jul 6, 2019

@Araq Araq closed this in 64e1408 Jul 6, 2019

narimiran added a commit that referenced this issue Jul 8, 2019

fixes #8316 (#11673)
(cherry picked from commit 64e1408)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.