mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 14:06:16 +02:00
eqValues/assertEqValues: Clean up assertions
It's still paranoid, and probably a waste of words, but at least now it's consistent and readily identifyable from a log.
This commit is contained in:
parent
61577402ba
commit
56bf39e905
1 changed files with 9 additions and 13 deletions
|
@ -2631,17 +2631,12 @@ void EvalState::assertEqValues(Value & v1, Value & v2, const PosIdx pos, std::st
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case nThunk: // Must not be left by forceValue
|
case nThunk: // Must not be left by forceValue
|
||||||
default:
|
assert(false);
|
||||||
// This should never happen, because eqValues already throws an
|
default: // Note that we pass compiler flags that should make `default:` unreachable.
|
||||||
// error for this, and this function should only be called when
|
// Also note that this probably ran after `eqValues`, which implements
|
||||||
// eqValues has found a difference, and it should match
|
// the same logic more efficiently (without having to unwind stacks),
|
||||||
// its behavior.
|
// so maybe `assertEqValues` and `eqValues` are out of sync. Check it for solutions.
|
||||||
// Note that as of writing, we make the compiler require that all enum
|
error<EvalError>("assertEqValues: cannot compare %1% with %2%", showType(v1), showType(v2)).withTrace(pos, errorCtx).panic();
|
||||||
// values are handled explicitly with `case`s, _despite_ having a
|
|
||||||
// `default:`.
|
|
||||||
error<EvalBaseError>(
|
|
||||||
"BUG: cannot compare %1% with %2%; did forceValue leave a thunk, or might assertEqValues be out of sync with eqValues?", showType(v1), showType(v2))
|
|
||||||
.debugThrow();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2723,8 +2718,9 @@ bool EvalState::eqValues(Value & v1, Value & v2, const PosIdx pos, std::string_v
|
||||||
return v1.fpoint() == v2.fpoint();
|
return v1.fpoint() == v2.fpoint();
|
||||||
|
|
||||||
case nThunk: // Must not be left by forceValue
|
case nThunk: // Must not be left by forceValue
|
||||||
default:
|
assert(false);
|
||||||
error<EvalError>("cannot compare %1% with %2%", showType(v1), showType(v2)).withTrace(pos, errorCtx).debugThrow();
|
default: // Note that we pass compiler flags that should make `default:` unreachable.
|
||||||
|
error<EvalError>("eqValues: cannot compare %1% with %2%", showType(v1), showType(v2)).withTrace(pos, errorCtx).panic();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue