better support for view types (#15436)

* you can put borrows into tables

* enforces mutating views only mutate mutable data
This commit is contained in:
Andreas Rumpf 2020-09-30 20:44:18 +02:00 • committed by GitHub
commit 86d7b63e2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 139 additions and 11 deletions

View file

@ -142,8 +142,10 @@ proc fixupCall(p: BProc, le, ri: PNode, d: var TLoc,
proc genBoundsCheck(p: BProc; arr, a, b: TLoc)
proc reifiedOpenArray(n: PNode): bool {.inline.} =
let x = trees.getRoot(n)
if x != nil and x.kind == skParam:
var x = n
while x.kind in {nkAddr, nkHiddenAddr, nkHiddenStdConv, nkHiddenDeref}:
x = x[0]
if x.kind == nkSym and x.sym.kind == skParam:
result = false
else:
result = true