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

Fix arrow parsing; avoid extra block nodes in AST #3136

Merged
merged 2 commits into from
Mar 29, 2024
Merged

Fix arrow parsing; avoid extra block nodes in AST #3136

merged 2 commits into from
Mar 29, 2024

Conversation

berekuk
Copy link
Collaborator

@berekuk berekuk commented Mar 29, 2024

This fixes #3110, and also fixes #2670, and also simplifies grammar and AST (see tests in diff for examples).

Previously:

$ node dist/cli/index.js parse -e 'x=5'
(Program
  (LetStatement
    :x
    (Block 5)
  )
)

Now:

$ node dist/cli/index.js parse -e 'x=5'
(Program
  (LetStatement :x 5)
)

The arrow bug in particular was caused by parsing let statements as lambdas first, before falling back on arbitrary expressions. I don't know why it was there; there might be some obscure case where this is a technically breaking change, but all tests are parsed and I hope it's fine.

Note that this doesn't give us any significant performance improvements; I already unwrap single-expression blocks during compilation.

(Which is good because otherwise I'd be worried about this change; I remember that some time ago skipping these block nodes wasn't safe).

@berekuk berekuk requested a review from OAGr as a code owner March 29, 2024 02:32
Copy link

changeset-bot bot commented Mar 29, 2024

🦋 Changeset detected

Latest commit: 4ce0af0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@quri/squiggle-lang Patch
@quri/squiggle-components Patch
@quri/prettier-plugin-squiggle Patch
@quri/versioned-squiggle-components Patch
vscode-squiggle Patch
@quri/squiggle-textmate-grammar Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Mar 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

4 Ignored Deployments
Name Status Preview Updated (UTC)
quri-hub ⬜️ Ignored (Inspect) Visit Preview Mar 29, 2024 2:33am
quri-ui ⬜️ Ignored (Inspect) Visit Preview Mar 29, 2024 2:33am
squiggle-components ⬜️ Ignored (Inspect) Visit Preview Mar 29, 2024 2:33am
squiggle-website ⬜️ Ignored (Inspect) Visit Preview Mar 29, 2024 2:33am

@OAGr
Copy link
Contributor

OAGr commented Mar 29, 2024

hm...
image
Hub preview is down. Not sure why though.

@berekuk
Copy link
Collaborator Author

berekuk commented Mar 29, 2024

Previews on specific commits don't work anymore (I mentioned this in https://quri.slack.com/archives/C06KPA4MGU9/p1711572884389439?thread_ts=1711571253.986579&cid=C06KPA4MGU9 yesterday), but previews on branches do: https://quri-hub-git-prettier-bug-quantified-uncertainty.vercel.app/

@OAGr
Copy link
Contributor

OAGr commented Mar 29, 2024

Huh, interesting, thanks!

@OAGr
Copy link
Contributor

OAGr commented Mar 29, 2024

Great, I can confirm that this works!

@OAGr OAGr merged commit d69717c into main Mar 29, 2024
6 checks passed
@OAGr OAGr deleted the prettier-bug branch March 29, 2024 18:23
@github-actions github-actions bot mentioned this pull request May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
2 participants