better support for slices as views (#15414)

* moved view tests to tests/views
* refactoring
* more refactorings
* better support for system.toOpenArray for first class view types
This commit is contained in:
Andreas Rumpf 2020-09-27 09:20:10 +02:00 • committed by GitHub
commit 57b7841c18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 100 additions and 44 deletions

View file

@ -1,18 +0,0 @@
discard """
errormsg: "cannot borrow"
nimout: '''tcannot_borrow.nim(16, 7) Error: cannot borrow meh; what it borrows from is potentially mutated
tcannot_borrow.nim(17, 3) the mutation is here
tcannot_borrow.nim(16, 7) is the statement that connected the mutation to the parameter'''
line: 16
"""
{.experimental: "views".}
type
Foo = object
field: string
proc dangerous(s: var seq[Foo]) =
let meh: lent Foo = s[0]
s.setLen 0
echo meh.field