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