diff options
author | Bung <crc32@qq.com> | 2022-10-30 00:04:05 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-29 18:04:05 +0200 |
commit | a51ed90c5ddc49d96dd96a16716f91fd543c518e (patch) | |
tree | 116225b5d8598fb603339e6c072a2e4d8c4c3898 /compiler/vm.nim | |
parent | 534c97edc54ffb6d55baa5084f8c426a451c9244 (diff) | |
download | Nim-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.nim | 5 |
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: |