Skip to content

Commit

Permalink
fixes nim-lang#24476; remove proc type cast if they are same types fo…
Browse files Browse the repository at this point in the history
…r backends (nim-lang#24480)

fixes nim-lang#24476

closes nim-lang#24479
  • Loading branch information
ringabout authored Nov 27, 2024
1 parent 8881017 commit 5340005
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 2 additions & 0 deletions compiler/ccgexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2520,6 +2520,8 @@ proc genSomeCast(p: BProc, e: PNode, d: var TLoc) =
putIntoDest(p, d, e, cDeref(cCast(ptrType(destTyp), wrapPar(cAddr(val)))), a.storage)
elif etyp.kind == tyBool and srcTyp.kind in IntegralTypes:
putIntoDest(p, d, e, cOp(NotEqual, rdCharLoc(a), cIntValue(0)), a.storage)
elif etyp.kind == tyProc and srcTyp.kind == tyProc and sameBackendType(etyp, srcTyp):
expr(p, e[1], d)
else:
if etyp.kind == tyPtr:
# generates the definition of structs for casts like cast[ptr object](addr x)[]
Expand Down
3 changes: 1 addition & 2 deletions compiler/vtables.nim
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ proc dispatch(x: Base, params: ...) =

var disp = newNodeI(nkIfStmt, base.info)

var vTableAccess = newNodeIT(nkBracketExpr, base.info, base.typ)
let nimGetVTableSym = getCompilerProc(g, "nimGetVTable")
let ptrPNimType = nimGetVTableSym.typ.n[1].sym.typ

Expand All @@ -33,7 +32,7 @@ proc dispatch(x: Base, params: ...) =
dispatchObject,
newIntNode(nkIntLit, index)
)
getVTableCall.typ() = base.typ
getVTableCall.typ() = getSysType(g, unknownLineInfo, tyPointer)
var vTableCall = newNodeIT(nkCall, base.info, base.typ.returnType)
var castNode = newTree(nkCast,
newNodeIT(nkType, base.info, base.typ),
Expand Down

0 comments on commit 5340005

Please sign in to comment.