Opened 7 months ago

Last modified 5 weeks ago

#9392 new bug

"\n" is displayed weirdly in error messages

Reported by: Artyom.Kazak Owned by:
Priority: low Milestone:
Component: Compiler Version: 7.8.3
Keywords: newcomer Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Other Test Case:
Blocked By: Blocking:
Related Tickets: #9681 Differential Revisions:

Description

Observe:

Prelude> "a\nb" + ()

<interactive>:2:10:
    Couldn't match expected type ‘[Char]’ with actual type ‘()’
    In the second argument of ‘(+)’, namely ‘()’
    In the expression:
      "a\n\
      \b"
      + ()

Moreover, if “\n” is at the end of the string, it simply gets eaten:

Prelude> "a\n" + ()

<interactive>:3:9:
    Couldn't match expected type ‘[Char]’ with actual type ‘()’
    In the second argument of ‘(+)’, namely ‘()’
    In the expression: "a" + ()

It happens in GHC as well as GHCi. Tested on 7.8.3.

Change History (4)

comment:1 Changed 4 months ago by thomie

  • Keywords newcomer added

The problem with a newline at the end of a string was fixed in #9681, slated for GHC 7.10.1. Let's leave this issue open for the formatting issue.

comment:2 Changed 3 months ago by jlengyel

  • Owner set to jlengyel

comment:3 Changed 3 months ago by jlengyel

  • Owner jlengyel deleted

comment:4 Changed 5 weeks ago by rwbarton

The formatting is intentional, see #4436. It would be nice to use the original syntax, though (and set the "original syntax" of a quasiquoter to use the multiline thing).

Note: See TracTickets for help on using tickets.