summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rw-r--r--compiler/cgen.nim10
1 files changed, 9 insertions, 1 deletions
diff --git a/compiler/cgen.nim b/compiler/cgen.nim
index a52d41999..287a6f5e4 100644
--- a/compiler/cgen.nim
+++ b/compiler/cgen.nim
@@ -1070,7 +1070,11 @@ proc allPathsAsgnResult(p: BProc; n: PNode): InitResultEnum =
       if result != Unknown: return result
   of nkAsgn, nkFastAsgn, nkSinkAsgn:
     if n[0].kind == nkSym and n[0].sym.kind == skResult:
-      if not containsResult(n[1]): result = InitSkippable
+      if not containsResult(n[1]):
+        if allPathsAsgnResult(p, n[1]) == InitRequired:
+          result = InitRequired
+        else:
+          result = InitSkippable
       else: result = InitRequired
     elif containsResult(n):
       result = InitRequired
@@ -1148,6 +1152,10 @@ proc allPathsAsgnResult(p: BProc; n: PNode): InitResultEnum =
         allPathsInBranch(n[i])
   of nkRaiseStmt:
     result = InitRequired
+  of nkChckRangeF, nkChckRange64, nkChckRange:
+    # TODO: more checks might need to be covered like overflow, indexDefect etc.
+    # bug #22852
+    result = InitRequired
   else:
     for i in 0..<n.safeLen:
       allPathsInBranch(n[i])