summary refs log tree commit diff stats
path: root/compiler/vm.nim
diff options
context:
space:
mode:
authorBung <crc32@qq.com>2022-10-30 00:04:05 +0800
committerGitHub <noreply@github.com>2022-10-29 18:04:05 +0200
commita51ed90c5ddc49d96dd96a16716f91fd543c518e (patch)
tree116225b5d8598fb603339e6c072a2e4d8c4c3898 /compiler/vm.nim
parent534c97edc54ffb6d55baa5084f8c426a451c9244 (diff)
downloadNim-a51ed90c5ddc49d96dd96a16716f91fd543c518e.tar.gz
fix #20148 implicit compile time conversion int to ranged float cause… (#20698)
fix #20148 implicit compile time conversion int to ranged float causes compiler fatal error
Diffstat (limited to 'compiler/vm.nim')
-rw-r--r--compiler/vm.nim5
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/vm.nim b/compiler/vm.nim
index 865ee1ea6..1a41ce8a1 100644
--- a/compiler/vm.nim
+++ b/compiler/vm.nim
@@ -460,9 +460,12 @@ proc opConv(c: PCtx; dest: var TFullReg, src: TFullReg, desttyp, srctyp: PType):
           else: int(src.intVal != 0)
     of tyFloat..tyFloat64:
       dest.ensureKind(rkFloat)
-      case skipTypes(srctyp, abstractRange).kind
+      let srcKind = skipTypes(srctyp, abstractRange).kind
+      case srcKind
       of tyInt..tyInt64, tyUInt..tyUInt64, tyEnum, tyBool, tyChar:
         dest.floatVal = toBiggestFloat(src.intVal)
+      elif src.kind == rkInt:
+        dest.floatVal = toBiggestFloat(src.intVal)
       else:
         dest.floatVal = src.floatVal
     of tyObject: