Opened 6 months ago

Closed 3 months ago

#13986 closed bug (fixed)

TypeApplications causes parse errors in @-patterns with certain Unicode characters

Reported by: Tikhon Owned by:
Priority: normal Milestone: 8.4.1
Component: Compiler (Parser) Version: 8.0.1
Keywords: TypeApplications Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC rejects valid program Test Case: parser/should_compile/T13986.hs
Blocked By: Blocking:
Related Tickets: Differential Rev(s): phab:D4105
Wiki Page:

Description (last modified by Tikhon)

The following function definition works without TypeApplications but fails to parse with the extension enabled:

{-# LANGUAGE TypeApplications #-}
module Mininal where

foo x₁@True = 10

It also parses correctly with "x" in place of "x₁".

Parse error:

Minimal.hs:5:1-11: error: …
    Parse error in pattern: foo x₁ @True
Compilation failed.

Change History (5)

comment:1 Changed 6 months ago by Tikhon

Description: modified (diff)

comment:2 Changed 6 months ago by RyanGlScott

Keywords: TypeApplications added

comment:3 Changed 3 months ago by harpocrates

Differential Rev(s):

comment:4 Changed 3 months ago by Ben Gamari <ben@…>

In 821adee1/ghc:

Fix a bug in 'alexInputPrevChar'

The lexer hacks around unicode by squishing any character into a 'Word8'
and then storing the actual character in its state. This happens at

That is all and well, but we ought to be careful that the characters we
retrieve via 'alexInputPrevChar' also fit this convention.

In fact, #13986 exposes nicely what can go wrong: the regex in the left
context of the type application rule uses the '$idchar' character set
which relies on the unicode hack. However, a left context corresponds
to a call to 'alexInputPrevChar', and we end up passing full blown
unicode characters to '$idchar', despite it not being equipped to deal
with these.

Test Plan: Added a regression test case

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13986

Differential Revision:

comment:5 Changed 3 months ago by bgamari

Differential Rev(s):
Milestone: 8.4.1
Resolution: fixed
Status: newclosed
Test Case: parser/should_compile/T13986.hs
Note: See TracTickets for help on using tickets.