Skip to content

Commit

Permalink
Improve cast safety
Browse files Browse the repository at this point in the history
Co-authored-by: Théophane Hufschmitt <[email protected]>
  • Loading branch information
edolstra and thufschmitt authored Dec 13, 2022
1 parent b3fdab2 commit 1315133
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/libcmd/repl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ static std::ostream & showDebugTrace(std::ostream & out, const PosTable & positi
// prefer direct pos, but if noPos then try the expr.
auto pos = dt.pos
? dt.pos
: (std::shared_ptr<AbstractPos>) positions[dt.expr.getPos() ? dt.expr.getPos() : noPos];
: static_cast<std::shared_ptr<AbstractPos>>(positions[dt.expr.getPos() ? dt.expr.getPos() : noPos]);

if (pos) {
out << pos;
Expand Down
4 changes: 2 additions & 2 deletions src/libexpr/eval.cc
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ void EvalState::runDebugRepl(const Error * error, const Env & env, const Expr &
? std::make_unique<DebugTraceStacker>(
*this,
DebugTrace {
.pos = error->info().errPos ? error->info().errPos : (std::shared_ptr<AbstractPos>) positions[expr.getPos()],
.pos = error->info().errPos ? error->info().errPos : static_cast<std::shared_ptr<AbstractPos>>(positions[expr.getPos()]),
.expr = expr,
.env = env,
.hint = error->info().msg,
Expand Down Expand Up @@ -1246,7 +1246,7 @@ void EvalState::cacheFile(
*this,
*e,
this->baseEnv,
e->getPos() ? (std::shared_ptr<AbstractPos>) positions[e->getPos()] : nullptr,
e->getPos() ? static_cast<std::shared_ptr<AbstractPos>>(positions[e->getPos()] : nullptr),
"while evaluating the file '%1%':", resolvedPath)
: nullptr;

Expand Down

0 comments on commit 1315133

Please sign in to comment.