Skip to content
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

Latest version of parser #917

Merged
merged 2 commits into from
Feb 11, 2024
Merged

Latest version of parser #917

merged 2 commits into from
Feb 11, 2024

Conversation

zth
Copy link
Collaborator

@zth zth commented Feb 7, 2024

Closes #915

@zth zth requested a review from cristianoc February 7, 2024 15:34
posCursor:[30:12] posNoWhite:[30:11] Found expr:[30:10->32:4]
posCursor:[30:12] posNoWhite:[30:11] Found expr:[30:10->30:12]
JSX <di:[30:10->30:12] > _children:None
posCursor:[30:12] posNoWhite:[30:11] Found expr:[15:8->33:2]
Copy link
Collaborator

Choose a reason for hiding this comment

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

which location is correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure actually. Think it's a problem?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Depends on whether they're wrong or fixed now.

Copy link
Collaborator

@cristianoc cristianoc Feb 8, 2024

Choose a reason for hiding this comment

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

Not sure why the output is different, but it's this test:

    <div>
      {React.string(someProp)}
      <div> {React.null} </div>
      // {someString->st}
      //                ^com
      // {"Some string"->st}
      //                   ^com
      // {"Some string"->Js.String2.trim->st}
      //                                    ^com
      // {someInt->}
      //           ^com
      // {12->}
      //      ^com
      // {someArr->a}
      //            ^com
      // <di
      //    ^com
    </div>

I think when completing di, it finds the following /div and now considers that "div" as a prop of di, while before it did not.

The one thing that comes to mind is that the treatment of nested jsx could have changed with the jsx mode pops etc in this:
rescript-lang/rescript#6609

@tsnobip any thoughts?
Not sure there's anything to do, just double checking if anything comes to mind. Otherwise we can just go ahead.

Copy link
Contributor

Choose a reason for hiding this comment

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

it is totally possible that my PR accidentally created some regressions, do you have an example in mind of syntax that should not be recognized but is now? I could add tests. I'm not really happy about working with the syntax parser right now, especially around mode, I think it can introduce bugs that are hard to spot.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, we should likely add tests around this. I'm not sure what's the best way to do that.
Basically, before, jsx mode tended to "leak" outside of jsx, which created unwanted behavior like accepting hyphens in identifiers outside of jsx. I tightened the jsx mode to avoid that, but I might have restricted it too much. I might have popped jsx mode one time too many.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It could be that the difference here is because jsx mode is now correctly restored while before it was not.
In which case that's great.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've tested this for a bit and I can't find any obvious issues with it. Not tests fail either from what I see. I'd like to merge this, because 2 other PRs depend on this, but I'd also not want to drop the ball here on if this change actually is problematic. How can we investigate it further? Add tests in the syntax for nested JSX mode?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This can be merged.
One can add a couple of tests of nested jsx separately in the compiler.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@tsnobip would you be up for adding tests for various forms of nested JSX in the compiler repo?

@zth zth merged commit a4d9c0a into master Feb 11, 2024
5 checks passed
@zth zth deleted the up-parser branch February 11, 2024 19:39
aspeddro pushed a commit to aspeddro/rescript-vscode that referenced this pull request Mar 4, 2024
* latest version of parser

* changelog
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.

Update parser to handle new array spreads
3 participants