Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix determinism bug from new combined ruleset code #406

Merged
merged 3 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ impl Display for Id {
#[derive(Clone, Debug)]
/// The egglog internal representation of already compiled rules
pub(crate) enum Ruleset {
Rules(Symbol, HashMap<Symbol, CompiledRule>),
/// Represents a ruleset with a set of rules.
/// Use an [`IndexMap`] to ensure egglog is deterministic.
/// Rules added to the [`IndexMap`] first apply their
/// actions first.
Rules(Symbol, IndexMap<Symbol, CompiledRule>),
/// A combined ruleset may contain other rulesets.
Combined(Symbol, Vec<Symbol>),
}

Expand Down
6 changes: 4 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1100,8 +1100,10 @@ impl EGraph {
match rules {
Ruleset::Rules(_, rules) => {
match rules.entry(name) {
Entry::Occupied(_) => panic!("Rule '{name}' was already present"),
Entry::Vacant(e) => e.insert(compiled_rule),
indexmap::map::Entry::Occupied(_) => {
panic!("Rule '{name}' was already present")
}
indexmap::map::Entry::Vacant(e) => e.insert(compiled_rule),
};
Ok(name)
}
Expand Down
Loading