Opened 3 years ago

Closed 19 months ago

#9803 closed bug (fixed)

Poor error message for unbound variable in pattern synonym

Reported by: goldfire Owned by: mpickering
Priority: normal Milestone:
Component: Compiler (Type checker) Version: 7.9
Keywords: PatternSynonyms Cc: mpickering
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect warning at compile-time Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

When I say

pattern OneElt = [x]

I get

    Right-hand side of bidirectional pattern synonym cannot be used as an expression
      [x]

I have two complaints with this error message:

  1. It's very unclear what's actually wrong with the pattern -- [x] looks like a perfectly fine expression, until I realize that x is unbound.
  2. The herald of the error is more than 80 characters (if you count the indentation) and wraps on my 80-character terminal. GHC tends to avoid this elsewhere, and so the wrapping is suboptimal.

I would easily say that issue (1) is more important than issue (2).

Perhaps this would be better:

    Variable `x' is unbound in the bidirectional pattern synonym `OneElt':
      [x]

Change History (5)

comment:1 Changed 3 years ago by thomie

Cc: cactus added
Component: CompilerCompiler (Type checker)

comment:2 Changed 23 months ago by thomie

Cc: mpickering added; cactus removed
Keywords: PatternSynonyms added
Type of failure: None/UnknownIncorrect warning at compile-time

comment:3 Changed 22 months ago by mpickering

Owner: set to mpickering

I will do this. I should wait for Simon to finish on #11224.

comment:4 Changed 22 months ago by simonpj

OK Matthew, you're all set to look at this.

comment:5 Changed 19 months ago by mpickering

Resolution: fixed
Status: newclosed

Simon got to this whilst doing some other cleanup.

Note: See TracTickets for help on using tickets.