mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
fixes #4345
This commit is contained in:
@@ -1568,11 +1568,12 @@ proc genSomeCast(p: BProc, e: PNode, d: var TLoc) =
|
||||
[getTypeDesc(p.module, e.typ), rdCharLoc(a)], a.s)
|
||||
|
||||
proc genCast(p: BProc, e: PNode, d: var TLoc) =
|
||||
const floatTypes = {tyFloat..tyFloat128}
|
||||
const ValueTypes = {tyFloat..tyFloat128, tyTuple, tyObject,
|
||||
tyArray, tyArrayConstr}
|
||||
let
|
||||
destt = skipTypes(e.typ, abstractRange)
|
||||
srct = skipTypes(e.sons[1].typ, abstractRange)
|
||||
if destt.kind in floatTypes or srct.kind in floatTypes:
|
||||
if destt.kind in ValueTypes or srct.kind in ValueTypes:
|
||||
# 'cast' and some float type involved? --> use a union.
|
||||
inc(p.labels)
|
||||
var lbl = p.labels.rope
|
||||
|
||||
8
tests/ccgbugs/tuplecast.nim
Normal file
8
tests/ccgbugs/tuplecast.nim
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
# bug #4345
|
||||
|
||||
# only needs to compile
|
||||
proc f(): tuple[a, b: uint8] = (1'u8, 2'u8)
|
||||
|
||||
let a, b = f()
|
||||
let c = cast[int](b)
|
||||
Reference in New Issue
Block a user