#7671 closed bug (fixed)

No break spaces

Reported by: zenzike Owned by:
Priority: normal Milestone: 7.8.1
Component: Compiler (Parser) Version: 7.6.2
Keywords: alex lexer Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: T7671 Blocked By:
Blocking: Related Tickets:

Description

I thought I was going mad when the following code wasn't compiling:

{-# LANGUAGE UnicodeSyntax #-}
{-# LANGUAGE RankNTypes #-}

type F f = forall x . f x

GHC was producing the following error message:

mad.hs:4:21
    Illegal symbol '.' in type
    Perhaps you intended -XRankNTypes or similar flag
    to enable explicit-forall syntax: forall <tvs>. <type>

It turns out that I had somehow inserted a unicode no break space, character code U+00a0, in the line importing RankNTypes, just after the first #. Baffling.

This begs the question: should GHC treat this unicode space as an ordinary space when the UnicodeSyntax extension is enabled? If not should there have been some warning that I had inserted this symbol in a language pragma?

Change History (3)

comment:1 Changed 14 months ago by igloo

  • Component changed from Compiler to Compiler (Parser)
  • Difficulty set to Unknown
  • Keywords alex lexer added
  • Milestone set to 7.8.1
  • Test Case set to T7671

Thanks for the report. This is meant to work, but it's broken.

It looks like what's going wrong is that known_pragma is assuming that len is a number of bytes, but it's actually a number of characters. It therefore sees -#\160LAN[...] when it expects {-#\160LAN[...].

comment:2 Changed 14 months ago by ian@…

commit c68aac1f2e59d0844a285b757777b950da91a8be

Author: Ian Lynagh <ian@well-typed.com>
Date:   Tue Feb 26 01:27:43 2013 +0000

    Fix parsing of pragmas containing unicode characters; fixes #7671

 compiler/parser/Lexer.x |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

comment:3 Changed 14 months ago by igloo

  • Resolution set to fixed
  • Status changed from new to closed

Fixed

Note: See TracTickets for help on using tickets.