summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2016-08-23 01:10:34 +0200
committerAndreas Rumpf <rumpf_a@web.de>2016-08-23 01:10:34 +0200
commite9e413552af0480747d025d422a0ea9500c582a2 (patch)
tree0b6a80f129e6915e22f3f36c607fab5d9ba488bc /compiler
parent9c9a7b6520e45cc71f071e82e8306ad276d72258 (diff)
downloadNim-e9e413552af0480747d025d422a0ea9500c582a2.tar.gz
fixes #4619
Diffstat (limited to 'compiler')
-rw-r--r--compiler/semstmts.nim10
1 files changed, 8 insertions, 2 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index 5d1770a32..5f9989ea2 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -304,8 +304,14 @@ proc semTry(c: PContext, n: PNode): PNode =
 proc fitRemoveHiddenConv(c: PContext, typ: PType, n: PNode): PNode =
   result = fitNode(c, typ, n)
   if result.kind in {nkHiddenStdConv, nkHiddenSubConv}:
-    changeType(result.sons[1], typ, check=true)
-    result = result.sons[1]
+    let r1 = result.sons[1]
+    if r1.kind in {nkCharLit..nkUInt64Lit} and typ.skipTypes(abstractRange).kind in {tyFloat..tyFloat128}:
+      result = newFloatNode(nkFloatLit, BiggestFloat r1.intVal)
+      result.info = n.info
+      result.typ = typ
+    else:
+      changeType(r1, typ, check=true)
+      result = r1
   elif not sameType(result.typ, typ):
     changeType(result, typ, check=false)