Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#7901 closed bug (fixed)

Bad error message when using UnicodeSyntax ∀ without ExplicitForall

Reported by: exbb2 Owned by: ajp
Priority: normal Milestone:
Component: Compiler Version: 7.6.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect warning at compile-time Test Case: parser/should_fail/ParserNoForallUnicode
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

This code

{-# LANGUAGE UnicodeSyntax #-}

id' :: ∀ a. a → a
id' a = a

produces following error

/tmp/id.hs:4:8: parse error on input `∀'

However, equivalent code without unicode syntax gives a much better error message:

id' :: forall a. a → a
id' a = a
/tmp/id.hs:4:16:
    Illegal symbol '.' in type
    Perhaps you intended -XRankNTypes or similar flag
    to enable explicit-forall syntax: forall <tvs>. <type>

Change History (13)

comment:1 Changed 6 years ago by ajp

difficulty: Unknown
Owner: set to ajp

comment:2 Changed 6 years ago by ptc

I did some hacking on this earlier this week, and thought I'd add this patch which removes some dead code, and changes the lexer to check the same extensions for unicode forall as ascii forall.

comment:3 Changed 6 years ago by simonpj

Status: newpatch

Changed 6 years ago by ajp

Changed 6 years ago by ajp

comment:4 Changed 6 years ago by ajp

This is my first attempt at working on ghc, so any feedback is appreciated. All functional changes are in 0002-Improve... - 0001-Minor-cleanups... removes some dead code and extraneous whitespace that I came across, but can easily be discarded.

comment:5 Changed 6 years ago by thoughtpolice

Thanks to the both of you. These patches look fine; I'll validate/merge them shortly.

comment:6 Changed 6 years ago by Austin Seipp <aseipp@…>

In 96adf0e99b1a6595ee40ef9c05263a4fe73eb7c5/ghc:

Improve error when using forall with UnicodeSyntax

Fixes Trac #7901.

'∀' is neither upper nor lowercase, unlike the 'f' in 'forall', so when
explicit forall is not enabled, it creates a parse error before reaching
the '.', which is where we give a nice message for ascii 'forall'.
Therefore, we make '∀' into a token as long as UnicodeSyntax is enabled,
which is safe because its caselessness means it can never be mistaken
for a symbol, and check extensions in the parser when the 'forall' rule
is used.

Authored-by: Paul Cavallaro <ptc@fb.com>
Authored-by: Anders Papitto <anderspapitto@gmail.com>
Signed-off-by: Austin Seipp <aseipp@pobox.com>

comment:7 Changed 6 years ago by Austin Seipp <aseipp@…>

In 5535416500167a1167bf8b375acf999ad4b20924/testsuite:

Test case for #7901.

Signed-off-by: Austin Seipp <aseipp@pobox.com>

comment:8 Changed 6 years ago by thoughtpolice

Resolution: fixed
Status: patchclosed

comment:9 Changed 6 years ago by simonpj

Test Case: parser/should_fail/ParserNoForallUnicode
Note: See TracTickets for help on using tickets.