elm-lang.org icon indicating copy to clipboard operation
elm-lang.org copied to clipboard

Try Elm error line numbers are off by one

Open martimatix opened this issue 8 years ago • 2 comments

If you break the Hello World example in Try Elm as shown below:

import Html exposing (text)

main =
  tex "Hello, World!"

The error message is as follows:

Cannot find variable `tex`

5|   tex "Hello, World!"

Notice that it says the error occurs on line 5 but it actually occurs on line 4. This is the case with all errors displayed while using Try Elm. That is to say, they are off by one.

martimatix avatar Dec 11 '16 21:12 martimatix

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

process-bot avatar Dec 11 '16 21:12 process-bot

The reason for this and #679 is that a module line is prepended to the program before it is compiled (at addHeader), e.g. module Temp1481492898786019 exposing (..). This gives the program a random module name.

The only problem I can see with removing this line (and having the module name implicitly be Main) is that parallel compilation of different programs would use the same intermediary .elmi and .elmo files, leading to a race condition.

spikefoo avatar Jan 03 '17 18:01 spikefoo