Skip to content

Commit 2903495

Browse files
Declare the InvalidOpsWithReturn struct and register it on the TestDialect Dialect
Signed-off-by: Tomas Fabrizio Orsi <[email protected]>
1 parent 2df05bd commit 2903495

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

hir/src/derive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ mod tests {
136136

137137
use crate::{
138138
attributes::Overflow,
139-
dialects::test::{self, Add},
139+
dialects::test::{self, Add, InvalidOpsWithReturn},
140140
Builder, BuilderExt, Context, Op, Operation, Report, Spanned,
141141
};
142142

hir/src/dialects/test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ impl DialectRegistration for TestDialect {
115115

116116
fn register_operations(info: &mut DialectInfo) {
117117
info.register_operation::<ops::Add>();
118+
info.register_operation::<ops::InvalidOpsWithReturn>();
118119
info.register_operation::<ops::Mul>();
119120
info.register_operation::<ops::Shl>();
120121
info.register_operation::<ops::Ret>();

hir/src/dialects/test/ops/binary.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,19 @@ impl InferTypeOpInterface for Shl {
7474
Ok(())
7575
}
7676
}
77+
78+
/// Invalid operation that breaks the SameOperandsAndResultType trait
79+
#[operation(
80+
dialect = TestDialect,
81+
traits(BinaryOp, SameTypeOperands, SameOperandsAndResultType),
82+
)]
83+
pub struct InvalidOpsWithReturn {
84+
#[operand]
85+
lhs: AnyInteger,
86+
#[operand]
87+
rhs: AnyInteger,
88+
#[result]
89+
result: AnyUnsignedInteger,
90+
#[attr]
91+
overflow: Overflow,
92+
}

0 commit comments

Comments
 (0)