Skip to content

Copy by value does not work in JS #347

@reactormonk

Description

@reactormonk
var a = newSeq[proc():int]()
for i in [1,2,3,4]:
  var j = i
  var fun = proc():int = j
  a.add(fun)

for fun in a: echo(fun())

Produces in C:

1
2
3
4

Produces in JS:

4
4
4
4

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions