-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use the new update-field AIR support to simplify assignment though a path in AIR #1359
base: main
Are you sure you want to change the base?
Conversation
Co-Authored-By: Andrea Lattuada <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, it looks good. I just have a few changes that I've requested.
return Ok(t1); | ||
if t1 != *s { | ||
Err(format!( | ||
"in field-update, argument type {:?} does not match struct type {:?}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe "datatype type" instead of "struct type"?
@@ -0,0 +1,61 @@ | |||
#![feature(rustc_private)] | |||
#[macro_use] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These look like copies of tests from other test files. If the tests are already in some other place, we don't have to have a second copy here. For refactoring an existing feature (like field update) for which tests already exist, we don't necessarily have to have a new test file.
); | ||
let bop = air::ast::BinaryOp::FieldUpdate(acc); | ||
if typ_is_poly(ctx, field_typ) && !typ_is_poly(ctx, &value_typ) { | ||
value = try_box(ctx, value, &value_typ).expect("box field update"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If possible, I'd like to see boxing/unboxing coercions inserted by poly.rs rather than by sst_to_air.rs. The ongoing monomorphize
branch, for example, would have to add special cases to sst_to_air.rs whenever sst_to_air.rs performs boxing/unboxing operations directly, whereas everything in poly.rs will automatically be skipped by monomorphize
.
This replaces code that takes a snapshot of the pre-state of the assignment, assumes the new value for the changed field and then assumes that all other fields (on each datatype of the path) are unchanged:
All this can be replaced with a single assignment using
update-field
:This was primarily developed by @tim-rohde.