Upstream Pexp_hole - #300
Open
dra27 wants to merge 5 commits into
Open
Conversation
The -dparsetree output for `.` ran the following line of output onto the same line as "Pexp_unreachable". No expected test output includes this constructor, so no references change. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A new toplevel test records the current behaviour of the wildcard "_" appearing in expression positions: - "~_:" and "?_:" already lex as labels named "_", so e.g. `g ~_:3` is already legal; - where a general expression can start, the parser recognizes "_" via an ad hoc rule in order to report "wildcard \"_\" not expected"; - where only a simple expression is allowed (function-argument positions), "_" is a plain syntax error. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The ad hoc "wildcard \"_\" not expected" rule moves from fun_expr to simple_expr, and two new rules recognize the labelled-argument sugar `~_` and `?_`. All positions where "_" can appear as an expression now report the ad hoc message instead of a generic syntax error. UNDERSCORE joins the "first tokens of simple_expr" precedence group so that it is shifted as a function argument. All the new rules and the precedence are inside BEGIN/END AVOID markers, since they still exist only to report an error: the AVOID-stripped grammar is byte-for-byte unchanged, so the generated-parse-errors corpus is unaffected. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The wildcard "_" now parses as an expression (a "hole", Pexp_hole) anywhere a simple expression is allowed, including the labelled argument sugar `~_` and `?_`. Holes are unconditionally rejected by the type-checker with the same "wildcard \"_\" not expected" message previously reported by the parser: they are intended to be eliminated by a ppx rewriter before type-checking (merlin already uses Pexp_hole as its error-recovery placeholder). This matches oxcaml (PRs oxcaml/oxcaml#3310 and oxcaml/oxcaml#4956), with three deliberate differences: Pprintast prints holes from simple_expr (avoiding a spurious "(_)" in argument positions), Printast terminates the "Pexp_hole" line properly, and the typing error goes through Error.log_and_raise for typing recovery. The generated-parse-errors corpus is not regenerated: the committed sentences still all produce the same errors, and regenerating churns thousands of unrelated lines (Menhir has changed its choice of representative start symbols since the corpus was last generated, and the generate-parse-errors recipe predates the current ocamltest TEST syntax). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.