Skip to content

Add bar position to case #7407

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

Merged
merged 2 commits into from
Apr 26, 2025
Merged

Add bar position to case #7407

merged 2 commits into from
Apr 26, 2025

Conversation

nojaf
Copy link
Collaborator

@nojaf nojaf commented Apr 26, 2025

This is useful in recovery scenarios:

let x  = 
    switch y {
        | None => 0
        |
    }
[
  structure_item 
    Pstr_value Nonrec
    [
      <def>
        pattern 
          Ppat_var "x" 
        expression 
          Pexp_match
          expression 
            Pexp_ident "y" 
          [
            <case>
            | [3,25+8]
              pattern 
                Ppat_construct "None" 
                None
              expression 
                Pexp_constant PConst_int (0,None)
            <case>
            | [4,45+8]
              pattern 
                Ppat_extension "rescript.patternhole"
                []
              expression 
                Pexp_extension "rescript.exprhole"
                []
          ]
    ]
]

we can pinpoint a cursor position between the bar and the end of the switch.
Easily telling us that we are inside an empty case.

@nojaf nojaf marked this pull request as ready for review April 26, 2025 10:24
Copy link
Collaborator

@zth zth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff! @cristianoc any comments?

@cristianoc
Copy link
Collaborator

Looks great

@zth zth merged commit c610a12 into rescript-lang:master Apr 26, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants