-
-
Notifications
You must be signed in to change notification settings - Fork 96
Allow range of const record elements in case choice #1354
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
base: master
Are you sure you want to change the base?
Conversation
e382d60 to
40d8503
Compare
|
CI found another issue. I forgot to check if the tree node is already a But now I'm not terribly happy about the function name: static tree_t simp_case_choice(tree_t t, simp_ctx_t *ctx);Because it suggests that it handles the whole choice. But it only handles the name or left/right subnode. But naming wise in tree_t eval_try_fold_locally_static(tree_t expr, unit_registry_t *ur, mir_context_t *mc);What would you prefer? |
40d8503 to
a7b83af
Compare
Well most are but there are some exceptions.
How about |
| tree_t rf = simp_case_choice(r, ctx); | ||
| if (r != rf) | ||
| tree_set_right(range, rf); |
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.
| tree_t rf = simp_case_choice(r, ctx); | |
| if (r != rf) | |
| tree_set_right(range, rf); | |
| tree_set_right(range, simp_case_choice(r, ctx)); |
(and elsewhere)
There's no harm in setting it to the same value and looks less noisy.
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.
I'd agree and that was actually how I initially did it. But with that I get several crashes of Fatal: Write to object in frozen arena. Is there something else I need to account for?
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.
I guess that happens because simp_case is called from simp_tree_global as well simp_tree_local (I can't remember why) and the T_ALTERNATIVE won't necessarily have a writable copy during elaboration.
I think you could probably fix that by moving this logic to a new simp_case_alternative() that's called from simp_tree_local only for T_ALTERNATIVE.
I've extended our solution to #1347 with the capability to handle a range of constant record elements.
I don't think a slice i.e. association subkind
A_SLICEis possible here. So I've left that out.Cheers, Nik