lumo icon indicating copy to clipboard operation
lumo copied to clipboard

Compiler errors and warnings should be complete and consistent

Open fkrull opened this issue 6 years ago • 5 comments

Right now, the compiler prints warnings and error messages in inconsistent formats and, in some cases, missing information. For example, compare a warning:

WARNING: Use of undeclared Var name.space/var at line 4

with one line of a compile error:

name.space [line 8, col 1] Unexpected EOF while reading item 2 of list, starting at line 4 and column 1. at line 8 name.space

This inconsistency makes it very challenging to parse the compiler output to extract warnings and errors, e.g. using Visual Studio Code's problem matchers.

Ideally, all warnings and errors should be logged in a consistent, easily regex-able format, with one line per item that contains a severity marker, the file name, line, column, and message.

fkrull avatar Oct 12 '17 22:10 fkrull

This is inherited party from ClojureScript and also one of my concerns. Especially regarding the warnings, which are not actual errors and therefore not treated like that. I think someone else already proposed a :warning-as-error feature and together with better logging (JS maybe?) this can be solved.

arichiardi avatar Oct 13 '17 00:10 arichiardi

Another thing you can do is to wrap you lumo.build.api/build call with:

(ana/with-warning-handlers [(handler-fn ws)] 
        (build/build (build/inputs ...)

You can see an example of this in the tests: https://github.com/anmonteiro/lumo/blob/master/src/test/lumo/lumo/build_api_tests.cljs#L292

I wonder though if we should add an actual switch for it so that lumo does it automatically. Seeking opinions /cc @anmonteiro

EDIT: also found this blog post

arichiardi avatar Oct 17 '17 00:10 arichiardi

FWIW, you can find my attempts at solving this here. However, even with that:

  • Some exceptions had an entirely different structure than the ones I print in that code (no examples off the top of my head, unfortunately); usually, these were lacking line info or file names.
  • I did have some success using a warning handler to collect warnings, but I couldn't figure out how to get useful file names from those. Since that was kind of the point, I abandoned that effort.

Never mind that useful error messages shouldn't be optional for a compiler, but here we are.

fkrull avatar Oct 18 '17 12:10 fkrull

Yes warning don't contain file names for the most part, I noticed that too. Is the JVM compiler giving some more info? Maybe this is an upstream issue.

arichiardi avatar Jan 31 '18 05:01 arichiardi

This is particularly evident in these cases (using expoud here):

throw ex;
^
Error: Call to #'pkg.util/promise-chan did not conform to spec:
<filename missing>:<line number missing>

-- Spec failed --------------------

Function arguments

  (1)
   ^

should satisfy

  (fn [%] (instance? js/Promise %))



-------------------------
Detected 1 error

arichiardi avatar Jan 31 '18 20:01 arichiardi