Try expanding aliases in Ctype.nondep_type_rec#10005
Conversation
|
I understand the patch and I think it makes sense.
Currently the code in the Question: two other cases in this function ( I think the code could be rewritten to look as follows: try
Option.iter
(fun id -> raise (Nondep_cannot_erase id))
(Path.find_free_opt ids p);
Tconstr(p, List.map ...)
with Nondep_cannot_erase _ as e ->
match nondep_expansion () with
| Some res -> res
| None -> raise e |
c3a6e1b to
f236eb6
Compare
No, expansion only has any effect for
I found the |
gasche
left a comment
There was a problem hiding this comment.
Thanks! The code looks good to me, and I feel that I understand it enough to approve.
f236eb6 to
a64ab32
Compare
|
This makes sense to me too. |
|
This is old code indeed. From memory:
|
|
Indeed; we would argue that we are "forced" to expand the abbreviation here, as otherwise the equation gets erased, we strictly lose information, and typing may fail later down the road. |
|
I agree with @gasche: this patch expands only in cases where nondep would otherwise fail. @xavierleroy does that answer your concern? |
|
I am considering merging this if we don't have further feedback in the next few days. I think Xavier's feedback was more of an encouragement for other people to voice potential concerns, so we should be fine if no concerns are voiced. |
|
Yes, I'm reassured. Users will still not like the weird recursive types they get after expansion of a big object type or variant type, but that's better than failing. |
Ctype.nondep_type_rec sometimes fails to expand aliases:
Trunk currently gives
M : sig type s end, because it cannot writeX.t always_intwithout mentioningX. However, by expandingX.t always_int, it could give insteadM : sig type s = int end, which is what you'd get if you manually expandedX.t always_inttoint.This patch always expands if nondep fails.