Skip to content

Commit

Permalink
Preventing box values from being const-folded.
Browse files Browse the repository at this point in the history
commit-id:96c96792
  • Loading branch information
orizi committed Apr 14, 2024
1 parent 50f0be8 commit 3bb90f4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ pub fn const_folding(db: &dyn LoweringGroup, lowered: &mut FlatLowered) {
lowered.variables[inputs[0].var_id].ty,
val.clone().into(),
);
var_info.insert(outputs[0], VarInfo::Const(value.clone()));
// Not inserting the value into the `var_info` map because the
// resulting box isn't an actual const at the Sierra level.
*stmt =
Statement::Const(StatementConst { value, output: outputs[0] });
}
Expand Down
6 changes: 6 additions & 0 deletions tests/bug_samples/issue5411.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use core::nullable::NullableTrait;

#[test]
fn box_of_box() -> Nullable<Box<u32>> {
NullableTrait::<Box<u32>>::new(BoxTrait::new(16))
}
1 change: 1 addition & 0 deletions tests/bug_samples/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ mod issue4318;
mod issue4380;
mod issue4897;
mod issue4937;
mod issue5411;
mod loop_break_in_match;
mod loop_only_change;
mod partial_param_local;
Expand Down

0 comments on commit 3bb90f4

Please sign in to comment.