Skip to content

compiler crashes when getting item from big array at compile time #7059

@nitely

Description

@nitely

The compiler crashes when trying to compile this code:

proc genArray(): array[100000, int] =
  discard

const myarr = genArray()

proc foo(a: int): int =
  return myarr[a]

proc main() =
  const a = foo(0)
  echo a
main()

output:

Error: internal error: (filename: "vmgen.nim", line: 179, column: 16)
No stack traceback available
To create a stacktrace, rerun compilation with ./koch temp c <file>

I was actually trying to create a dummy example, where it would crash here [0] but I ended it up making it crash here [1] . It seems like it is the same issue, though.

[0]

internalAssert(-0x7fff < diff and diff < 0x7fff)

[1]
internalAssert result < 0x7fff

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