summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rw-r--r--compiler/parampatterns.nim11
1 files changed, 8 insertions, 3 deletions
diff --git a/compiler/parampatterns.nim b/compiler/parampatterns.nim
index 9ca9f110d..8540f1b32 100644
--- a/compiler/parampatterns.nim
+++ b/compiler/parampatterns.nim
@@ -183,8 +183,15 @@ proc exprRoot*(n: PNode): PSym =
   while true:
     case it.kind
     of nkSym: return it.sym
+    of nkHiddenDeref, nkDerefExpr:
+      if it[0].typ.skipTypes(abstractInst).kind in {tyPtr, tyRef}:
+        # 'ptr' is unsafe anyway and 'ref' is always on the heap,
+        # so allow these derefs:
+        break
+      else:
+        it = it[0]
     of nkDotExpr, nkBracketExpr, nkHiddenAddr,
-       nkObjUpConv, nkObjDownConv, nkCheckedFieldExpr, nkHiddenDeref:
+       nkObjUpConv, nkObjDownConv, nkCheckedFieldExpr:
       it = it[0]
     of nkHiddenStdConv, nkHiddenSubConv, nkConv:
       it = it[1]
@@ -199,8 +206,6 @@ proc exprRoot*(n: PNode): PSym =
       else:
         break
     else:
-      # nkDerefExpr: assume the 'var T' addresses
-      # the heap and so the location is not on the stack.
       break
 
 proc isAssignable*(owner: PSym, n: PNode; isUnsafeAddr=false): TAssignableResult =