refactor(tvix/eval): administer antidote for poison

The codebase contains a lot of complexity and odd roundabout
handling for shadowing globals.  I'm pretty sure none of this is
necessary, and all of it disappears if you simply make the globals
part of the ordinary identifier resolution chain, with their own
scope up above the root scope.  Then the ordinary shadowing routines
do the right thing, and no special cases or new terminology are
required.

This commit does that.

Note by tazjin: This commit was originally abandoned when Adam decided
not to take away reviewer bandwidth for this at the time (eval was
still in a much earlier stage). As we've recently done some
significant refactoring of globals initialisation this came up again,
and it seems we can easily cover the use-cases of the poison tracking
in other ways now, so I've rebased, updated and resurrected the CL.

Co-Authored-By: Vincent Ambo <tazjin@tvl.su>
Signed-off-by: Adam Joseph <adam@westernsemico.com>
Change-Id: Ib3309a47a7b31fa5bf10466bade0d876b76ae462
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7089
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
This commit is contained in:
Adam Joseph 2022-10-25 02:23:22 -07:00 committed by tazjin
parent ab8486e5b8
commit 22b9e6ff09
8 changed files with 49 additions and 135 deletions

View file

@ -37,10 +37,10 @@ fn is_lit_bool(expr: ast::Expr) -> LitBool {
fn optimise_bin_op(c: &mut Compiler, slot: LocalIdx, expr: ast::Expr) -> ast::Expr {
use ast::BinOpKind;
// bail out of this check if the user has poisoned either `true`
// bail out of this check if the user has overridden either `true`
// or `false` identifiers. Note that they will have received a
// separate warning about this for shadowing the global(s).
if c.scope().is_poisoned("true") || c.scope().is_poisoned("false") {
if c.is_user_defined("true") || c.is_user_defined("false") {
return expr;
}