view types: spec changes (#18226)
* view types: spec changes * Update doc/manual_experimental.rst Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> * Update doc/manual_experimental.rst Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
This commit is contained in:
parent
3481ff6172
commit
2ea7287217
3 changed files with 21 additions and 24 deletions
|
|
@ -572,7 +572,7 @@ proc borrowingAsgn(c: var Partitions; dest, src: PNode) =
|
|||
borrowFrom(c, dest.sym, src)
|
||||
elif dest.kind in {nkHiddenDeref, nkDerefExpr, nkBracketExpr}:
|
||||
case directViewType(dest[0].typ)
|
||||
of mutableView:
|
||||
of mutableView, immutableView:
|
||||
# we do not borrow, but we use the view to mutate the borrowed
|
||||
# location:
|
||||
let viewOrigin = pathExpr(dest, c.owner)
|
||||
|
|
@ -580,12 +580,13 @@ proc borrowingAsgn(c: var Partitions; dest, src: PNode) =
|
|||
let vid = variableId(c, viewOrigin.sym)
|
||||
if vid >= 0:
|
||||
c.s[vid].flags.incl viewDoesMutate
|
||||
of immutableView:
|
||||
#[of immutableView:
|
||||
if dest.kind == nkBracketExpr and dest[0].kind == nkHiddenDeref and
|
||||
mutableParameter(dest[0][0]):
|
||||
discard "remains a mutable location anyhow"
|
||||
else:
|
||||
localError(c.g.config, dest.info, "attempt to mutate a borrowed location from an immutable view")
|
||||
]#
|
||||
of noView: discard "nothing to do"
|
||||
|
||||
proc containsPointer(t: PType): bool =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue