Skip to content

Javascript generation #7249

@alehander92

Description

@alehander92
import jsffi

var a = JsAssoc[cstring, int]{a: 2}

for z, b in a:
  echo b

proc f =
  var a = JsAssoc[cstring, int]{a: 2}

  for z, b in a:
    echo b

f()

when a is global, it's a "fat pointer": so it's an array with one element which is the actual object.
However the for loop is for (.. in a_) so it iterates through the array instead through it's [0].

If it's in a function, it works correctly, but because for some reason a is just the object instead of a fat pointer (which I am not sure why)

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