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

Compiler error produces unexpected output when rendered in a terminal #2302

Open
hovsater opened this issue Apr 10, 2023 · 3 comments
Open

Comments

@hovsater
Copy link

hovsater commented Apr 10, 2023

Quick Summary:

While working on https://github.com/hovsater/aoc-elm I encountered an error message that produces unexpected output inside a terminal. Specifically the error message seem to emit 65532 spaces in a row as @lydell kindly pointed out in #2302 (comment). Since the terminal wrap long lines, the result is a very long empty section to scroll through in the middle of the error message.

SSCCE

module Main exposing (main)

failingCode : List () -> List ()
failingCode list =
    case list of
        [ a, a ] -> list
        _ -> list
  • Elm: 0.19.1
  • Browser: None
  • Operating System: macOS Ventura 13.3

Additional Details

The problem can be produced when running with the JSON reporter as well (i.e., --report=json).

Here's the raw output from the terminal (produced by running script /tmp/output and then running /tmp/output through sed -n 'l'
Script started on Mon Apr 10 17:12:41 2023$
\033[?2004h~/code/elm-bug $ elm make --output=/dev/null src\
/Main.elm\r$
\033[?2004l\rCompiling ...\rDetected problems in 1 module.\
\r$
\033[36m-- NAME CLASH -------------------------------------\
---------------- src/Main.elm\033[0m\r$
\r$
This `case` pattern has multiple `a` variables.\r$
\r$
6|         [ a, a ] -> list\r$
                \033[91m^\033[0m                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
                                                           \
               \033[91m^\033[0m\r$
How can I know which one you want? Rename one of them!\r$
\r$
\033[?2004h~/code/elm-bug $ \033[?2004l\r\r$
exit\r$
$
Script done on Mon Apr 10 17:12:51 2023$
@github-actions
Copy link

Thanks for reporting this! To set expectations:

  • Issues are reviewed in batches, so it can take some time to get a response.
  • Ask questions in a community forum. You will get an answer quicker that way!
  • If you experience something similar, open a new issue. We like duplicates.

Finally, please be patient with the core team. They are trying their best with limited resources.

@lydell
Copy link
Contributor

lydell commented Apr 10, 2023

As far as I can tell, “breaks terminal rendering” is a bit of a red herring. What seems to happen is that line 6 of the error message contains 65532 spaces in a row. Terminals wrap long lines, which in effect results in a very long empty section to scroll through in the middle of the error message.

Here I replaced long sequences of a character like XXXXXXX… with {X}*42:

❯ elm make Main.elm 2> output.txt
Detected problems in 1 module.

❯ node -p 'fs.readFileSync("output.txt", "utf8").replace(/(.)\\1{5,}/g, m => `{${m[0]}}*${m.length}`)'
-- NAME CLASH {-}*57 Main.elm

This `case` pattern has multiple `a` variables.

6|{ }*9[ a, a ] -> list
{ }*16^{ }*65532^
How can I know which one you want? Rename one of them!

Random note: 65532 is suspiciously close to 2^16 = 65,536.

@hovsater hovsater changed the title Compiler error produces output that breaks terminal rendering Compiler error produces unexpected output Apr 10, 2023
@hovsater hovsater changed the title Compiler error produces unexpected output Compiler error produces unexpected output when rendered in a terminal Apr 10, 2023
@hovsater
Copy link
Author

As far as I can tell, “breaks terminal rendering” is a bit of a red herring.

You're right. That was probably some unfortunate wording on my part. I've updated the description accordingly. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants