-
Notifications
You must be signed in to change notification settings - Fork 8
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
improve option shape detection in Datarepr #23
base: master
Are you sure you want to change the base?
Conversation
Are you referring to the fact that the order is switched or the names are different (well it is both in this case). To be honest I thought that any data type isomorphic to |
| (
[ (a_id, ({cstr_args = []} as a_descr) ) ;
(b_id, ({ cstr_args = [_]} as b_descr))
] |
[ (a_id, ({cstr_args = [_]} as a_descr) ) ;
(b_id, ({ cstr_args = []} as b_descr))
]
) when (Ident.name a_id = "Some" && Ident.name b_id = "None") ||
(Ident.name a_id = "None" && Ident.name b_id = "Some") This pattern matching seems wrong because it accepts |
I applied this fix locally and saw no generated code changes. This tells me:
|
Doesn't this define a data type isomorphic to
So the question holds:
Why is this a bug? Is anything matches on constructor names in runtime (or their order)? |
Here's a playground link that shows the bug I'm speaking about.
type 'a opt_rev = None of 'a | Some No, we handle |
Hmm, actually my snippet just manages to reproduce the issue you pointed out. |
Can you point me to the place in code which does this? My understanding is that this happens after translcore which translates |
The thing is, even if you strengthen checks for a type to be exactly So maybe it makes sense to treat any type isomorphic to |
I thought the relevant section in translcore.ml from your patch in #22 did this.
which would probably render this PR useless? |
Well, yeah, but the check before was half baked anyway, e.g. checking only for
Probably. Anyway, need to create proper test suite for such behaviour. |
* feat: better EOF handling * wip
while reviewing #22, I noticed that the current code in
Datarepr.constructor_descrs
would assign a type such as the following an optional shape, when that's clearly wrong:cc @andreypopp