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

@ -121,7 +121,7 @@ proc typeAllowedAux(marker: var IntSet, typ: PType, kind: TSymKind,
{tyChar, tyEnum, tyInt..tyFloat128, tyInt..tyUInt64}: result = t
of tyOpenArray:
# you cannot nest openArrays/sinks/etc.
if (kind != skParam and views notin c.features) or taIsOpenArray in flags:
if (kind != skParam or taIsOpenArray in flags) and views notin c.features:
result = t
else:
result = typeAllowedAux(marker, t[0], kind, c, flags+{taIsOpenArray})