-
-
Notifications
You must be signed in to change notification settings - Fork 270
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
Type expansion #5559
base: main
Are you sure you want to change the base?
Type expansion #5559
Conversation
Co-authored-by: Ayaz <20735482+ayazhafiz@users.noreply.github.com> Signed-off-by: Ajai Nelson <22969541+AjaiKN@users.noreply.github.com>
@@ -572,9 +572,37 @@ pub struct WhenBranchPattern { | |||
pub degenerate: bool, | |||
} | |||
|
|||
#[derive(Clone, Debug, Default)] | |||
pub struct Refinements(VecMap<Symbol, (Variable, Variable)>); |
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.
What do you think about using a SmallVec
here instead (there is one in roc_collections)? The hypothesis is that typically, we have 1 or 0 symbols to refine.
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.
Sounds like a good idea!
LetAndExpandType( | ||
Index<LetConstraint>, | ||
Slice<Variable>, | ||
Option<Box<Refinements>>, |
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.
Is there a reason Refinements is boxed?
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 I don't box it, one of the size assertions fails for Constraint
:
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> crates/compiler/can/src/constraint.rs:731:1
|
731 | roc_error_macros::assert_sizeof_aarch64!(Constraint, 3 * 8);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: source type: `Constraint` (512 bits)
= note: target type: `[u8; 24]` (192 bits)
= note: this error originates in the macro `static_assertions::assert_eq_size` which comes from the expansion of the macro `roc_error_macros::assert_sizeof_aarch64` (in Nightly builds, run with -Z macro-backtrace for more info)
fn unique_symbol(ident_ids: &mut IdentIds, home: ModuleId) -> Symbol { | ||
let ident_id = ident_ids.gen_unique(); | ||
|
||
Symbol::new(home, ident_id) | ||
} |
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.
just fyi, there is a unique_symbol
on the Env
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.
Yeah, that's what I originally did in refine_tag_union
, but the borrow checker didn't like that I was both borrowing env.subs
and mutably borrowing env
. This unique_symbol()
acts on IdentIds
instead of Env
so that I can mutably borrow only env.ident_ids
.
# ^ [Io Str] | ||
Io "hi" -> Io "bye" | ||
error -> error | ||
# ^^^^^ [Io Str, Net Str]* |
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.
🔥
Thank you for your contribution! Sometimes PRs end up staying open for a long time without activity, which can make the list of open PRs get long and time-consuming to review. To keep things manageable for reviewers, this bot automatically closes PRs that haven’t had activity in 60 days. This PR hasn’t had activity in 30 days, so it will be automatically closed if there is no more activity in the next 30 days. Keep in mind that PRs marked |
First step in implementing refinement of tag unions