google / google/codeworld

Show formatting errors in Haskell mode

Open
#1,220 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Haskell
Stars
1.3k
Forks
201
PR merge metrics
No merged PRs in 30d

Description

Ctrl-I triggers a reformat in Haskell mode. But if it fails, you just get "Could not format your code. It may contains errors." Actually, Ormolu gives us a detailed exception. At the very least, we could link people to the location of the error, instead of opaquely claiming there was a problem somewhere in the file.

One might initially think that if there's a parse error, it will be highlighted anyway. But Ormolu actually finds more parse errors than we highlight. That's because it parses in Haddock mode, so e.g. a haddock comment that doesn't match a declaration will cause formatting to fail. Also, there are Ormolu errors that aren't parse errors, such as if CPP is enabled. So it's even more important that reformatting provides an explanation for why it failed.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.