This commit is contained in:
parent
5b195ab0f0
commit
04c48e3c5b
2 changed files with 17 additions and 0 deletions
|
|
@ -457,6 +457,7 @@ proc foldArrayAccess(m: PSym, n: PNode; idgen: IdGenerator; g: ModuleGraph): PNo
|
||||||
|
|
||||||
proc foldFieldAccess(m: PSym, n: PNode; idgen: IdGenerator; g: ModuleGraph): PNode =
|
proc foldFieldAccess(m: PSym, n: PNode; idgen: IdGenerator; g: ModuleGraph): PNode =
|
||||||
# a real field access; proc calls have already been transformed
|
# a real field access; proc calls have already been transformed
|
||||||
|
if n[1].kind != nkSym: return nil
|
||||||
var x = getConstExpr(m, n[0], idgen, g)
|
var x = getConstExpr(m, n[0], idgen, g)
|
||||||
if x == nil or x.kind notin {nkObjConstr, nkPar, nkTupleConstr}: return
|
if x == nil or x.kind notin {nkObjConstr, nkPar, nkTupleConstr}: return
|
||||||
|
|
||||||
|
|
|
||||||
16
tests/whenstmt/t19426.nim
Normal file
16
tests/whenstmt/t19426.nim
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
type
|
||||||
|
MyInt = object
|
||||||
|
bitWidth: int
|
||||||
|
|
||||||
|
template toRealType*(t: MyInt): typedesc =
|
||||||
|
when t.bitWidth == 32: int32
|
||||||
|
elif t.bitWidth == 64: int64
|
||||||
|
else: {.error.}
|
||||||
|
|
||||||
|
proc doFail(T: typedesc): T = default(T)
|
||||||
|
|
||||||
|
proc test =
|
||||||
|
const myInt = MyInt(bitWidth:32)
|
||||||
|
discard doFail(toRealType(myInt))
|
||||||
|
|
||||||
|
test()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue