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
parse errors with CPP #774
Comments
This is unfortunate, but intended behavior, the examples you mention only did work as a side effect previously. From the "Limitations" section in the README:
Basically, the code excerpts before an As a workaround, you can surround code which uses CPP in unsupported ways with magic comments, for example like this: {-# LANGUAGE CPP #-}
module Main where
{- ORMOLU_DISABLE -}
f = do
#ifdef FOO
putStrLn "foo"
#endif
let msg = "yo!"
putStrLn msg (and possibly with an |
Indeed, the fact that it used to work in that particular case was a side-effect of the old implementation, not intended behavior. While adding |
Alright, maybe the issue is smaller than I thought. It's just that running the new ormolu over graphql-engine, I got parse errors in ~half the files that use CPP, and the first example seemed like such an innocent use that I started questioning things. |
Yeah, on CI, we test formatting of e.g. graphql-engine, but we remove CPP: ormolu/nix/ormolize/default.nix Line 26 in 06b767c
I created #775 to feature this issue more prominently in the changelog. Thanks for checking back on this one! |
Thanks! Closing. |
Some of our use of CPP causes trouble for ormolu, compare tweag/ormolu#774. Specifically, for understandable reasons, it can't deal well with `#ifdef` use that is not at the top-level. This PR removes the problematic usage in ways that I hope are also a net non-loss regardless of helping out ormolu (or other tooling). - The default value for enabled APIs moves to the top level, next to the command line help, so they'll stay in sync more easily. - All the CPP around using `assertNFHere` is moved to one module. hasura/graphql-engine-mono#2361 GitOrigin-RevId: ed6e039
Describe the bug
Just tested out the new 0.3.0.0 release, and I see some weird errors around CPP / #ifdef.
Parse error:
Bad indentation:
Works:
Parse error:
This is on macOS with the release binary, perhaps something went wrong with that? Seems unlikely that this would have passed the test suite?
Environment
ormolu 0.3.0.0 HEAD 06b767c
using ghc-lib-parser 9.0.1.20210324
The text was updated successfully, but these errors were encountered: