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 views in VM and js give errors #16306

Closed
timotheecour opened this issue Dec 9, 2020 · 1 comment
Closed

openArray views in VM and js give errors #16306

timotheecour opened this issue Dec 9, 2020 · 1 comment

Comments

@timotheecour
Copy link
Member

timotheecour commented Dec 9, 2020

--experimental:views don't seem to work well with VM and js:
toOpenArray errors in VM, while using it in js as below gives: Error: internal error: genTypeInfo(tyOpenArray)

Example 1: vm

when true:
  {.experimental: "views".}
  proc test(x: openArray[int]) =
    let y: openArray[int] = toOpenArray(x, 0, 2)
    echo (y[0],)
  template fn=
    test([0,1,2,3,4,5])
  fn() # ok
  static: fn() # Error: cannot generate code for: mSlice

Current Output

Error: cannot generate code for: mSlice

Expected Output

works

Example 2: js

nim r -b:js main
Error: internal error: genTypeInfo(tyOpenArray)

when true:
  {.experimental: "views".}
  proc test(x: openArray[int]) =
    echo (toOpenArray(x, 1, 3),) # ok
    let y: openArray[int] = toOpenArray(x, 1, 3) # Error: internal error: genTypeInfo(tyOpenArray)
    echo (y,)
  var a = [0,1,2,3,4,5]
  test(a)

Possible Solution

see proposal in #16305 (comment)
related: #15952

Additional Information

@timotheecour timotheecour changed the title [experimental:views] can't use toOpenArray in VM: cannot generate code for: mSlice [views] can't use toOpenArray in VM: cannot generate code for: mSlice Dec 9, 2020
@timotheecour timotheecour changed the title [views] can't use toOpenArray in VM: cannot generate code for: mSlice can't use toOpenArray in VM: cannot generate code for: mSlice Dec 9, 2020
@timotheecour timotheecour changed the title can't use toOpenArray in VM: cannot generate code for: mSlice views: can't use toOpenArray in VM: cannot generate code for: mSlice Dec 10, 2020
@timotheecour timotheecour added VM see also `const` label Javascript labels Dec 10, 2020
@timotheecour timotheecour changed the title views: can't use toOpenArray in VM: cannot generate code for: mSlice openArray views in VM and js give errors Dec 10, 2020
@ringabout ringabout removed the VM see also `const` label label Oct 21, 2022
ringabout added a commit that referenced this issue Oct 21, 2022
narimiran pushed a commit that referenced this issue Oct 24, 2022
closes #19969; add testcase

(cherry picked from commit 1db25ff)
@ringabout
Copy link
Member

fixed by #21440

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants