ndmitchell / hlint

Haskell source code suggestions
Other
1.47k stars 196 forks source link

#error in source file causes hlint toprint stack trace #371

Open agentm opened 7 years ago

agentm commented 7 years ago

In this source file, we have:

#ifndef PROJECTM36_VERSION
#error PROJECTM36_VERSION is not defined
#endif

The version is passed in via cabal configuration so that the versioning is centralized. However, hlint actually gives up because of this:

hlint: #error PROJECTM36_VERSION is not defined
in src/bin/TutorialD/tutd.hs  at line 75 col 1
CallStack (from HasCallStack):
  error, called at ./Language/Preprocessor/Cpphs/CppIfdef.hs:113:21 in cpphs-1.20.8-JLeLxWRxjmm1BBYuZIZezR:Language.Preprocessor.Cpphs.CppIfdef

In this case, I can tack on --cpp-define PROJECTM36_VERSION=0.1, but it would be nice if this looked less like a crash and included a tip on how to resolve it.

ndmitchell commented 7 years ago

Makes sense. We should probably make runCpphs from https://github.com/ndmitchell/hlint/blob/4e669a7cd2a535212a04e0102373e53a24c384b3/src/HSE/All.hs#L53 return Either ParseError String, and catch any exceptions thrown out of cpphs.