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

Openarray: internal compiler error when accessing length if not a param #9281

mratsim opened this issue Oct 10, 2018 · 0 comments


None yet
2 participants
Copy link

commented Oct 10, 2018

If we try to access the length of an openarray that wasn't passed as a function parameter we crash.

Building on the example from #9279

template boundedOpenArray[T](x: seq[T], first, last: int): openarray[T] =
  toOpenarray(x, max(0, first), min(x.high, last))

proc foo[T](x: openarray[T]) =
  echo x.len

let a = @[1, 2, 3]

# a.boundedOpenArray(1, 2).foo()  # Works
echo a.boundedOpenArray(1, 2).len # Internal compiler error
Error: internal error: genMagicExpr: mSlice
No stack traceback available
To create a stacktrace, rerun compilation with ./koch temp c <file>

@Araq Araq closed this in d48e964 Oct 11, 2018

krux02 added a commit to krux02/Nim that referenced this issue Oct 15, 2018

narimiran added a commit to narimiran/Nim that referenced this issue Oct 31, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.