mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 12:07:51 +00:00
fixes #4619
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
3
tests/vm/tconst_float_as_int.nim
Normal file
3
tests/vm/tconst_float_as_int.nim
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
# bug #4619
|
||||
const x: float = 0
|
||||
Reference in New Issue
Block a user