fixes #4619
This commit is contained in:
parent
9c9a7b6520
commit
e9e413552a
2 changed files with 11 additions and 2 deletions
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue