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

Prevent the extension from crashing due to unparseable Dark code #5292

Merged
merged 3 commits into from
Feb 7, 2024

Conversation

OceanOak
Copy link
Collaborator

@OceanOak OceanOak commented Feb 6, 2024

Changelog:

Parser
- Update the parser to handle unparseable code 

This PR adds :

  • a new Unparseable type to the CliScript type to handle unparseable code and prevent the extension from crashing.
  • a --skip-self-update flag for the LSP to prevent running the self-update while using the extension
  • a "parse": "tree-sitter parse" command to tree-sitter-darklang

A stack overflow occurs when the number of tokens exceeds ~340, which is consistent with the List.map issue #5222

The issue lies in the SemanticTokens.toJson function, specifically in:

t.data
 |> Stdlib.List.map (fun d -> Json.Number(Stdlib.UInt64.toFloat d))
 |> Json.Array)

@OceanOak OceanOak changed the title wip: Handle unparseable code Prevent the extension from crashing due to unparseable Dark code Feb 7, 2024
@OceanOak OceanOak marked this pull request as ready for review February 7, 2024 08:58
Copy link
Member

@StachuDotNet StachuDotNet left a comment

Choose a reason for hiding this comment

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

Looks good! A few cleanups, but then good to merge.

I see there's a few places where we're returning Errors of Strings. I didn't look too closely, and suspect that those are OK -- that their contents are basically ignored, erased by an Unparseable thing, and that it's useful to keep around that string for the time when we include a Reason along with the failures. That said, worth a quick look to make sure we aren't returning a String anywhere we shouldn't

@StachuDotNet StachuDotNet merged commit b1b4931 into darklang:main Feb 7, 2024
8 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.

2 participants