From c8e5aa9655b071f0f8f8706ba0482a09d0ffc620 Mon Sep 17 00:00:00 2001 From: Yihong Zhang Date: Thu, 3 Oct 2024 23:54:06 -0700 Subject: [PATCH] fix names --- src/ast/desugar.rs | 6 ++++-- src/lib.rs | 4 ++-- src/scheduler.rs | 2 +- src/typechecking.rs | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/ast/desugar.rs b/src/ast/desugar.rs index 304ef265..e02992e3 100644 --- a/src/ast/desugar.rs +++ b/src/ast/desugar.rs @@ -246,7 +246,9 @@ pub(crate) fn desugar_command( rule, } => { let name = if name.as_str() == "" { - rule.to_string().replace('\"', "'") + // Adding a unique prefix because there may be duplicate rules (e.g., when + // processing a resugared egglog program). + desugar.get_fresh().to_string() + &rule.to_string().replace('\"', "'") } else { name.to_string() }; @@ -261,7 +263,7 @@ pub(crate) fn desugar_command( if let Some(new_rule) = add_semi_naive_rule(desugar, rule) { result.push(NCommand::NormRule { ruleset, - name: ("__seminaive-".to_string() + &name).into(), + name: (desugar.get_fresh().to_string() + &"__seminaive-" + &name).into(), rule: new_rule, }); } diff --git a/src/lib.rs b/src/lib.rs index 5dfd6fdd..389cd020 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -292,7 +292,7 @@ impl Default for EGraph { ); egraph.scheduler_constructors.insert( "backoff".into(), - Rc::new(|_| Box::new(scheduler::BackoffScheduler::default())), + Rc::new(|_| Box::::default()), ); egraph } @@ -1219,7 +1219,7 @@ impl EGraph { /// Get the current timestamp pub fn get_timestamp(&self) -> u32 { - return self.timestamp; + self.timestamp } /// Bump the timestamp by 1 diff --git a/src/scheduler.rs b/src/scheduler.rs index a597bdd1..477830e9 100644 --- a/src/scheduler.rs +++ b/src/scheduler.rs @@ -1,6 +1,6 @@ +use instant::{Duration, Instant}; use std::fmt::{Display, Formatter}; use std::mem; -use std::time::{Duration, Instant}; use crate::{CompiledRule, Error, HashSet, Ruleset, Symbol, Value}; diff --git a/src/typechecking.rs b/src/typechecking.rs index 816ed62e..07a7a785 100644 --- a/src/typechecking.rs +++ b/src/typechecking.rs @@ -325,7 +325,7 @@ impl TypeInfo { GenericSchedule::WithScheduler(span, scheduler, args, schedule) => { ResolvedSchedule::WithScheduler( span.clone(), - scheduler.clone(), + *scheduler, args.iter() .map(|arg| self.typecheck_expr(arg, &Default::default())) .collect::, _>>()?,