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

"AST of input and AST of formatted code differ" for block expressions applied to other expressions #444

Closed
neongreen opened this issue Nov 4, 2019 · 4 comments · Fixed by #472
Labels
bug Something isn't working

Comments

@neongreen
Copy link
Collaborator

neongreen commented Nov 4, 2019

main = 
  do
    x
    y
   z
main =
  do
    x
    y
    z
AST of input and AST of formatted code differ.
  at <input>:(2,3)-(5,4)
@neongreen neongreen added the bug Something isn't working label Nov 4, 2019
@neongreen neongreen changed the title "AST of input and AST of formatted code differ" for a do corner case "AST of input and AST of formatted code differ" for block expressions applied to other expressions Nov 4, 2019
@neongreen
Copy link
Collaborator Author

Same story:

main = 
  case foo of
    x -> a
   foo a b
main =
  case foo of
    x -> a
    foo
    a
    b
Parsing of formatted code failed:
  <input><rendered>:5:5
  parse error (possibly incorrect indentation or mismatched brackets)

@neongreen
Copy link
Collaborator Author

And:

main = do
  if x then y else z
 foo a b
main =
  do
    if x then y else z
    foo
    a
    b
AST of input and AST of formatted code differ.
  at <input>:(1,8)-(3,8)

@mrkkrp
Copy link
Member

mrkkrp commented Nov 29, 2019

Do you have an opinion regarding the fix? Should the arguments be aligned like this:

main =
  do
    x
    y
  z

main =
  case foo of
    x -> a
  foo a b

main =
  do
    if x then y else z
  foo a b

?

@mrkkrp
Copy link
Member

mrkkrp commented Nov 29, 2019

Removing indentation bump in this particular case seems to solve the problem. I do not understand why foo a b gets reformated into a multi-line application though. I think it should stay on single line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants