summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2020-11-20 18:14:15 +0100
committerGitHub <noreply@github.com>2020-11-20 18:14:15 +0100
commitd9038ed792b923cfbb9593ab82825fdb48728adc (patch)
tree8bce3de75e19aa97f056db84351b767492b452a9 /compiler
parentfcb2ec4ed69fe924e7e3899e0084f534124255d4 (diff)
downloadNim-d9038ed792b923cfbb9593ab82825fdb48728adc.tar.gz
fixes #15671 [backport:1.4] (#15690)
* fixes #15671 [backport:1.4]

* progress
Diffstat (limited to 'compiler')
-rw-r--r--compiler/typeallowed.nim14
1 files changed, 11 insertions, 3 deletions
diff --git a/compiler/typeallowed.nim b/compiler/typeallowed.nim
index e163b914a..c81819250 100644
--- a/compiler/typeallowed.nim
+++ b/compiler/typeallowed.nim
@@ -52,7 +52,7 @@ proc typeAllowedAux(marker: var IntSet, typ: PType, kind: TSymKind,
   result = nil
   if typ == nil: return nil
   if containsOrIncl(marker, typ.id): return nil
-  var t = skipTypes(typ, abstractInst-{tyTypeDesc})
+  var t = skipTypes(typ, abstractInst-{tyTypeDesc, tySink})
   case t.kind
   of tyVar, tyLent:
     if kind in {skProc, skFunc, skConst} and (views notin c.features):
@@ -60,7 +60,7 @@ proc typeAllowedAux(marker: var IntSet, typ: PType, kind: TSymKind,
     elif t.kind == tyLent and kind != skResult and (views notin c.features):
       result = t
     else:
-      var t2 = skipTypes(t[0], abstractInst-{tyTypeDesc})
+      var t2 = skipTypes(t[0], abstractInst-{tyTypeDesc, tySink})
       case t2.kind
       of tyVar, tyLent:
         if taHeap notin flags: result = t2 # ``var var`` is illegal on the heap
@@ -70,6 +70,8 @@ proc typeAllowedAux(marker: var IntSet, typ: PType, kind: TSymKind,
       of tyUncheckedArray:
         if kind != skParam and views notin c.features: result = t
         else: result = typeAllowedAux(marker, t2[0], kind, c, flags)
+      of tySink:
+        result = t
       else:
         if kind notin {skParam, skResult} and views notin c.features: result = t
         else: result = typeAllowedAux(marker, t2, kind, c, flags)
@@ -125,12 +127,18 @@ proc typeAllowedAux(marker: var IntSet, typ: PType, kind: TSymKind,
       result = t
     else:
       result = typeAllowedAux(marker, t[0], kind, c, flags+{taIsOpenArray})
-  of tyVarargs, tySink:
+  of tyVarargs:
     # you cannot nest openArrays/sinks/etc.
     if kind != skParam or taIsOpenArray in flags:
       result = t
     else:
       result = typeAllowedAux(marker, t[0], kind, c, flags+{taIsOpenArray})
+  of tySink:
+    # you cannot nest openArrays/sinks/etc.
+    if kind != skParam or taIsOpenArray in flags or t[0].kind in {tySink, tyLent, tyVar}:
+      result = t
+    else:
+      result = typeAllowedAux(marker, t[0], kind, c, flags)
   of tyUncheckedArray:
     if kind != skParam and taHeap notin flags:
       result = t