summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2024-08-22 13:20:00 +0800
committerGitHub <noreply@github.com>2024-08-22 07:20:00 +0200
commitac0179ced9a85a0a04f1e3d4f038fb989498d008 (patch)
tree46cc376b5308203ee20aa0c6f0599ee6978948c1 /compiler
parent2311049b27d6a46b6df53ecf4bbe73a598bedd65 (diff)
downloadNim-ac0179ced9a85a0a04f1e3d4f038fb989498d008.tar.gz
fixes #23943; simple default value for range (#23996)
fixes #23943

---------

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Diffstat (limited to 'compiler')
-rw-r--r--compiler/semstmts.nim5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index 7e55a7046..185441815 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -829,6 +829,11 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
     var typFlags: TTypeAllowedFlags = {}
 
     var def: PNode = c.graph.emptyNode
+    if typ != nil and typ.kind == tyRange and
+        c.graph.config.isDefined("nimPreviewRangeDefault") and
+        a[^1].kind == nkEmpty:
+      a[^1] = firstRange(c.config, typ)
+
     if a[^1].kind != nkEmpty:
       def = semExprWithType(c, a[^1], {efTypeAllowed}, typ)