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

hindent changes the meaning of the formatted code #532

Open
2 tasks done
facundominguez opened this issue Dec 20, 2018 · 0 comments
Open
2 tasks done

hindent changes the meaning of the formatted code #532

facundominguez opened this issue Dec 20, 2018 · 0 comments

Comments

@facundominguez
Copy link
Contributor

Problem

hindent changes the meaning of the formatted code, which would make unattended formatting rather dangerous.

  • I checked the issue tracker for existing issues about this problem.
  • I'm using the latest version of hindent.
$ cat test.hs
{-# LANGUAGE CPP #-}
main = print (g && f1)
  where
        f1 = h
          where
            h = True
#ifdef C1
g = g1
  where
    g1 = g2
      where
        g2 = False
#else
        g = True
#endif

#ifndef C1
g = False
#endif

$ runhaskell test.hs
True

$ hindent --version
hindent 5.2.7

$ hindent test.hs

$ runhaskell test.hs
False

Actual output haskell

{-# LANGUAGE CPP #-}

main = print (g && f1)
  where
    f1 = h
      where
        h = True
#ifdef C1
g = g1
  where
    g1 = g2
      where
        g2 = False
#else
        g = True
#endif

#ifndef C1
g = False
#endif

Perhaps there should be a way to disable parsing of CPP directives to reject this program.

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

No branches or pull requests

1 participant