Skip to content

Unable to have array of NimNodes declared with const #7317

@PMunch

Description

@PMunch

While trying to create a mapping table from strings to internal types for use in a macro I noticed I got weird errors when trying to have NimNodes in a const array:

static:
  let testArr = [parseExpr("int"), parseExpr("float")]
  const testArr2 = [parseExpr("int"), parseExpr("float")]

  echo testArr[0]
  echo testArr2[0]

This creates an error "Error: cannot generate VM code for int" for the second echo statement. Removing the echo statement makes it work fine, even with the declaration of the const. The let works fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions