Opened 5 years ago

Closed 5 years ago

#9634 closed bug (fixed)

"data X = 1": "Illegal literal in type (use DataKinds to enable): 1"

Reported by: rwbarton Owned by:
Priority: low Milestone:
Component: Compiler (Type checker) Version: 7.9
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: typecheck/should_fail/T9634
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


This error message is not good. "1" is not in a type position, and DataKinds will not help anything. Well, except the error message, which with DataKinds enabled is instead

parse error in constructor in data/newtype declaration: 1

If it's not hard, we should give that error message also when DataKinds is disabled.

Change History (2)

comment:1 Changed 5 years ago by Simon Peyton Jones <simonpj@…>

In ac157de3cd959a18a71fa056403675e2c0563497/ghc:

Complain about illegal type literals in renamer, not parser

A premature complaint was causing Trac #9634.  Acutally this
change also simplifies the lexer and eliminates duplication.
(The renamer was already making the check, as it happens.)

comment:2 Changed 5 years ago by simonpj

Resolution: fixed
Status: newclosed
Test Case: typecheck/should_fail/T9634

Good point, thank you. We now get

    Cannot parse data constructor in a data/newtype declaration: 1

whether or not DataKinds is on


Note: See TracTickets for help on using tickets.