egraphs: fix fill-in-the-types logic for multiple projections of one value. (#5112)

In particular, this was found to happen in #5099 because a `Result`
projection node was not deduplicating across two separate `isplit`s that
created it. (This is a separate issue we should also fix; `needs_dedup`
is I think overly conservative because `Result` can project out a single
value from a pure or impure node, but the projection itself should be
treated like any other pure operator.)

In any case, if we have a value `v0` and two separate `Result { value:
v0, result: N, ty }` nodes, each of these will fill in the type `ty` for
the `N`th output of `v0`, and the second will idempotently overwrite the
first; we should loosen the assert so that it allows this case.

Fixes #5099. Fixes #5100.
This commit is contained in:
Chris Fallin
2022-10-24 22:22:28 -07:00
committed by GitHub
parent 097d1087e0
commit e62e530b7c
2 changed files with 12 additions and 1 deletions

View File

@@ -276,7 +276,7 @@ impl DataFlowGraph {
/// Fill in the type of a value, only if currently invalid (as a placeholder).
pub(crate) fn fill_in_value_type(&mut self, v: Value, ty: Type) {
debug_assert!(self.values[v].ty().is_invalid());
debug_assert!(self.values[v].ty().is_invalid() || self.values[v].ty() == ty);
self.values[v].set_type(ty);
}