From e24a6fccb59040761df58c7a04b49eef96ba1690 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Tue, 26 Nov 2024 23:29:19 +0800 Subject: [PATCH] fixes #24476; fold proc convs if they are same types for backend --- compiler/semfold.nim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/semfold.nim b/compiler/semfold.nim index eb5db88fc9..eeadf00785 100644 --- a/compiler/semfold.nim +++ b/compiler/semfold.nim @@ -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