Improve cast safety

Co-authored-by: Théophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com>
This commit is contained in:
Eelco Dolstra 2022-12-13 12:38:33 +01:00 committed by GitHub
parent b3fdab28a2
commit 1315133b50
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -217,7 +217,7 @@ static std::ostream & showDebugTrace(std::ostream & out, const PosTable & positi
// prefer direct pos, but if noPos then try the expr. // prefer direct pos, but if noPos then try the expr.
auto pos = dt.pos auto pos = dt.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) { if (pos) {
out << pos; out << pos;

View file

@ -823,7 +823,7 @@ void EvalState::runDebugRepl(const Error * error, const Env & env, const Expr &
? std::make_unique<DebugTraceStacker>( ? std::make_unique<DebugTraceStacker>(
*this, *this,
DebugTrace { 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, .expr = expr,
.env = env, .env = env,
.hint = error->info().msg, .hint = error->info().msg,
@ -1246,7 +1246,7 @@ void EvalState::cacheFile(
*this, *this,
*e, *e,
this->baseEnv, 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) "while evaluating the file '%1%':", resolvedPath)
: nullptr; : nullptr;