fixes #4345
This commit is contained in:
parent
2d8572e948
commit
d455d58af6
2 changed files with 11 additions and 2 deletions
|
|
@ -1568,11 +1568,12 @@ proc genSomeCast(p: BProc, e: PNode, d: var TLoc) =
|
||||||
[getTypeDesc(p.module, e.typ), rdCharLoc(a)], a.s)
|
[getTypeDesc(p.module, e.typ), rdCharLoc(a)], a.s)
|
||||||
|
|
||||||
proc genCast(p: BProc, e: PNode, d: var TLoc) =
|
proc genCast(p: BProc, e: PNode, d: var TLoc) =
|
||||||
const floatTypes = {tyFloat..tyFloat128}
|
const ValueTypes = {tyFloat..tyFloat128, tyTuple, tyObject,
|
||||||
|
tyArray, tyArrayConstr}
|
||||||
let
|
let
|
||||||
destt = skipTypes(e.typ, abstractRange)
|
destt = skipTypes(e.typ, abstractRange)
|
||||||
srct = skipTypes(e.sons[1].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.
|
# 'cast' and some float type involved? --> use a union.
|
||||||
inc(p.labels)
|
inc(p.labels)
|
||||||
var lbl = p.labels.rope
|
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)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue