summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorDerek 呆 <116649+derekdai@users.noreply.github.com>2021-10-30 01:55:48 +0800
committerGitHub <noreply@github.com>2021-10-29 19:55:48 +0200
commitf755e452d2a2c7656f07793b7f01dc654a7c5253 (patch)
tree40c33b29583885a48ba2aaef2c8f9090e8dc18cb /compiler
parentcfdac6666f5772479724e082fb08c2db694d8d40 (diff)
downloadNim-f755e452d2a2c7656f07793b7f01dc654a7c5253.tar.gz
fix #18971 (#19070) [backport:1.6]
since the example code return value from global variable, instead
of first argument, the `n.len` is 1 which causes compiler crashes.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/varpartitions.nim2
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/varpartitions.nim b/compiler/varpartitions.nim
index 8f422face..709d00fa0 100644
--- a/compiler/varpartitions.nim
+++ b/compiler/varpartitions.nim
@@ -479,7 +479,7 @@ proc destMightOwn(c: var Partitions; dest: var VarIndex; n: PNode) =
         # calls do construct, what we construct must be destroyed,
         # so dest cannot be a cursor:
         dest.flags.incl ownsData
-      elif n.typ.kind in {tyLent, tyVar}:
+      elif n.typ.kind in {tyLent, tyVar} and n.len > 1:
         # we know the result is derived from the first argument:
         var roots: seq[(PSym, int)]
         allRoots(n[1], roots, RootEscapes)