fixes #24476; fold proc convs if they are same types for backend

This commit is contained in:
ringabout
2024-11-26 23:29:19 +08:00
parent e7f48cdd5c
commit e24a6fccb5

View File

@@ -777,7 +777,8 @@ proc getConstExpr(m: PSym, n: PNode; idgen: IdGenerator; g: ModuleGraph): PNode
var a = getConstExpr(m, n[1], idgen, g)
if a == nil: return
if n.typ != nil and n.typ.kind in NilableTypes and
not (n.typ.kind == tyProc and a.typ.kind == tyProc):
(n.typ.kind != tyProc or a.typ.kind != tyProc or
sameBackendType(n.typ, a.typ)):
# we allow compile-time 'cast' for pointer types:
result = a
result.typ() = n.typ