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 #2924. Use MegaParsec scanner for Markdown files #2925

Merged
merged 4 commits into from
Jul 30, 2024
Merged

Conversation

jonaprieto
Copy link
Collaborator

@jonaprieto jonaprieto commented Jul 29, 2024

This PR addresses a bug/missing case present since v0.6.2, introduced specifically by

That PR involves detecting imports in Juvix files before type checking, and that's the issue.
Detecting/scanning imports is done by running a flat parser (which ignores the Juvix Markdown structure) and when it fails, it runs a Megaparser parse. So, for simplicity,
we could just continue using the same Megaparser as before for Juvix Markdown files.

@jonaprieto jonaprieto requested a review from janmasrovira July 29, 2024 18:33
@jonaprieto jonaprieto self-assigned this Jul 29, 2024
@jonaprieto jonaprieto added this to the 0.6.5 milestone Jul 29, 2024
@jonaprieto jonaprieto changed the title Fix:ImportScan parsing for Juvix Markdown files Fixes #2924: scanning import statements for Juvix Markdown files Jul 29, 2024
@jonaprieto jonaprieto marked this pull request as ready for review July 29, 2024 18:46
Copy link
Collaborator

@janmasrovira janmasrovira left a comment

Choose a reason for hiding this comment

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

I suggest adding a comment to clarify

@jonaprieto
Copy link
Collaborator Author

jonaprieto commented Jul 30, 2024

@janmasrovira Could you please make Ormolu happy here.
My local version generates a vast delta. 😅

@janmasrovira
Copy link
Collaborator

@janmasrovira Could you please make Ormolu happy here. My local version generates a vast delta. 😅

Done! If you want you can install the same ormolu version that we use in CI with stack install ormolu --resolver=lts-21.25.

@janmasrovira janmasrovira changed the title Fixes #2924: scanning import statements for Juvix Markdown files Fix #2924. Use MegaParsec scanner for Markdown files Jul 30, 2024
@janmasrovira janmasrovira merged commit 2416f78 into main Jul 30, 2024
4 checks passed
@janmasrovira janmasrovira deleted the fix-regression branch July 30, 2024 21:51
@jonaprieto
Copy link
Collaborator Author

I tried:

stack install ormolu --resolver=lts-21.25
[1 of 3] Compiling Main             ( /Users/jonaprieto/.stack/setup-exe-src/setup-HwdwpEmb.hs, /Users/jonaprieto/.stack/setup-exe-src/setup-HwdwpEmb.o )
[2 of 3] Compiling StackSetupShim   ( /Users/jonaprieto/.stack/setup-exe-src/setup-shim-HwdwpEmb.hs, /Users/jonaprieto/.stack/setup-exe-src/setup-shim-HwdwpEmb.o )
[3 of 3] Linking /Users/jonaprieto/.stack/setup-exe-cache/aarch64-osx/tmp-Cabal-simple_HwdwpEmb_3.8.1.0_ghc-9.4.8
ld: unknown options: --gc-sections
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ghc-9.4.8: `gcc' failed in phase `Linker'. (Exit code: 1)

Error: [S-6374]
       While building simple Setup.hs (scroll up to its section to see the error) using:
       /Users/jonaprieto/.stack/programs/aarch64-osx/ghc-9.4.8/bin/ghc-9.4.8 -rtsopts -threaded -clear-package-db -global-package-db -hide-all-packages -package base -main-is StackSetupShim.mainOverride -package Cabal-3.8.1.0 /Users/jonaprieto/.stack/setup-exe-src/setup-HwdwpEmb.hs /Users/jonaprieto/.stack/setup-exe-src/setup-shim-HwdwpEmb.hs -o /Users/jonaprieto/.stack/setup-exe-cache/aarch64-osx/tmp-Cabal-simple_HwdwpEmb_3.8.1.0_ghc-9.4.8
       Process exited with code: ExitFailure 1

It's probably due to my mac.

janmasrovira added a commit that referenced this pull request Aug 2, 2024
- In #2925, the flatparse scanner
always fails for .md files and silently falls back to megaparsec.
- In #2929, a warning is introduced
that informs the user when the fallback parser is being used. This is
causing a warning every time we scan a markdown file.
- This pr fixes the problem by changing the default strategy to directly
use megaparsec when a .md file is given.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Typecheck fails on Juvix Markdown files containing the word "import".
2 participants