Replies: 1 comment
-
I don't remember the exact details, but this is a hack to get the levels right by either removing some sharing or avoiding some traversal that lowers levels. I was able to remove it in my patch to add polymorphic parameters by fixing the treatment of levels in I think it requires this commit to adjust |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I would like to understand the purpose of the following
(_ as x)
device in typecore.ml:ocaml/typing/typecore.ml
Lines 1900 to 1917 in b795460
Question: what is the purpose of the
Tpat_var
special case?cc @garrigue (and maybe @t6s, who worked on
type_pat
quite a bit recently?)Context
I am asking because this special case, combined with #12119, results in a change of typedtree emitted between 5.0 and the 5.1 release branch or trunk. Consider the following program
With 5.0, the typedtree generated corresponds to a
(x : int)
pattern (more precisely, pseudo-code would be{ pat = Ppat_var "x"; extra = Ppat_constraint "int" }
).With 5.1 or trunk, the typedtree generated corresponds to a
((_ as x) : int)
pattern ({ pat = Ppat_alias (Ppat_any, Ppat_var "x"); extra = Ppat_constraint "int" }
).This difference is causing me some minor issues down the line due to code that pattern-matches on the typedtree and has a special shortcut for
Ppat_var
, that ultimately interacts with code that @trefis and myself are writing to fix #7241.Observation
If I remove this special case, there is exactly one failure in the compiler testsuite. The following test:
now behaves as follows in
-principal
mode:I am not sure what is causing the difference, and whether this is the intended effect of the
(_ as x)
wrapping, or it was meant to change something else somewhere else (that may or may not still exists in the compiler today; the wrapping was introduced in the development branch of 4.00).If I understand correct, the warning comes from a difference in type-checking between the pattern
(n : #numeral)
and the pattern((_ as n) : #numeral)
(which only occurs in the wrapping is disabled in the type-checker).Beta Was this translation helpful? Give feedback.
All reactions