Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,262
    • Issues 4,262
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 419
    • Merge Requests 419
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #16999

Closed
Open
Opened Jul 27, 2019 by KevinBuhr@kabuhrDeveloper

GHC allows function arrow (->) as data constructor

As was pointed out in this SO question, GHC appears to incorrectly accept (->) as a valid "consym" in data declarations. That is, the following code compiles:

data Type
  = TBool
  | TInt
  | (->) Type Type

though attempts to use the constructor are correctly rejected as parse errors:

wontwork ((->) a b) = (->) b a  -- both "->" are parse errors

The expected behavior is that, since -> doesn't start with a colon, it ought to be rejected as a parse error.

I can duplicate this with GHC 8.6.5 and the latest HEAD.

The issue seems to be in tyConToDataCon which as per the Note "Parsing data constructors is hard" reinterprets a potential type constructor expression as a data constructor expression. It checks the validity of the constructor with isLexCon which calls isLexConSym, which specifically permits -> in addition to constructors that start with a colon (startsConSym).

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#16999