You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code fails, due to how lifetimes are encoded in melior, I think this should be valid code given MLIR ownership right?
The problem when dealing with BlockRefs and operation result values is they are wrongly tied to the BlockRef itself and not the block the blockref references i think
#[test]fnlifetimes(){let context = Context::new();let region = Region::new();let blockref = region.append_block(Block::new(&[]));fndo_stuff<'ctx:'region,'region>(context:&'ctx Context,_region:&'region Region<'ctx>,block:BlockRef<'ctx,'region>,) -> Value<'ctx,'region>{
block.append_operation(arith::constant(
context,IntegerAttribute::new(IntegerType::new(context,64).into(),1).into(),Location::unknown(context),)).result(0).unwrap().into()}let value = do_stuff(&context,®ion, blockref);}
error[E0515]: cannot return value referencing function parameter `block`
--> melior/src/ir/block.rs:580:13
|
580 | block.append_operation(arith::constant(
| ^----
| |
| _____________`block` is borrowed here
| |
581 | | context,
582 | | IntegerAttribute::new(IntegerType::new(context, 64).into(), 1).into(),
583 | | Location::unknown(context),
584 | | )).result(0).unwrap().into()
| |________________________________________^ returns a value referencing data owned by the current function
Some errors have detailed explanations: E0432, E0515.
For more information about an error, try `rustc --explain E0432`.
The text was updated successfully, but these errors were encountered:
For anyone seeing this issue, currently the API do not allow modifications of blocks or operations that are moved into the other objects like regions or blocks. So in the example above, we need to modify the block and complete it first, and then append the block to the region.
The following code fails, due to how lifetimes are encoded in melior, I think this should be valid code given MLIR ownership right?
The problem when dealing with BlockRefs and operation result values is they are wrongly tied to the BlockRef itself and not the block the blockref references i think
The text was updated successfully, but these errors were encountered: