diff --git a/crates/fayalite/src/module.rs b/crates/fayalite/src/module.rs index ac38ee8..144ca96 100644 --- a/crates/fayalite/src/module.rs +++ b/crates/fayalite/src/module.rs @@ -11,7 +11,7 @@ use crate::{ ops::VariantAccess, Expr, Flow, Target, TargetBase, TargetPathArrayElement, TargetPathBundleField, TargetPathElement, ToExpr, }, - int::{DynUInt, DynUIntType, FixedOrDynIntType, UInt}, + int::{DynUInt, DynUIntType, FixedOrDynIntType, IntValue, UInt}, intern::{Intern, Interned}, memory::{Mem, MemBuilder, MemBuilderTarget, PortName}, reg::Reg, @@ -2259,8 +2259,10 @@ where ) -> RegBuilder<'a, (), (), ()> { self.reg_builder_with_loc(implicit_name.0, SourceLocation::caller()) } + // intentionally takes Expr instead of impl ToExpr to help prevent + // `#[hdl] if a == b {}` instead of using `cmp_eq` #[track_caller] - pub fn if_(&mut self, cond: impl ToExpr) -> IfScope + pub fn if_(&mut self, cond: Expr>) -> IfScope where Ty: FixedOrDynIntType< 1, @@ -2273,7 +2275,7 @@ where } pub fn if_with_loc( &mut self, - cond: impl ToExpr, + cond: Expr>, source_location: SourceLocation, ) -> IfScope where @@ -2284,7 +2286,7 @@ where CanonicalValue = DynUInt, >, { - let cond = cond.to_expr().as_bool(); + let cond = cond.as_bool(); let outer_block = self.block_stack.top(); let then_block = self.new_block(); let else_block = self.new_block();