#7562 closed bug (fixed)

Parse error with {-# UNPACK #-} Int

Reported by: nomeata Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.6.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: typecheck/should_compile/T7562 Blocked By:
Blocking: Related Tickets:

Description

This code (note the missing !) causes a parser error:

module UnpackedFields where

data Pair2 = Pair2 {-# UNPACK #-} Int

I think a proper error message is more helpful. Also, the docs should mention that {-# UNPACK #-} can only be used on strict fields.

Change History (2)

comment:1 Changed 15 months ago by simonpj@…

commit deec5b74dee7f676b8a9f840ec7b5a813e7e0956

Author: Simon Peyton Jones <simonpj@microsoft.com>
Date:   Thu Jan 10 16:50:25 2013 +0000

    Be willing to parse {-# UNPACK #-} without '!'
    
    This change gives a more helpful error message when the
    user says    data T = MkT {-# UNPACK #-} Int
    which should have a strictness '!' as well. Rather than
    just a parse error, we get
    
      T7562.hs:3:14: Warning:
        UNPACK pragma lacks '!' on the first argument of `MkT'
    
    Fixes Trac #7562

 compiler/basicTypes/DataCon.lhs     |   40 +++++++++++++++++++++-------------
 compiler/basicTypes/MkId.lhs        |   29 +++++++++++++++++-------
 compiler/deSugar/DsMeta.hs          |    4 +-
 compiler/hsSyn/Convert.lhs          |    4 +-
 compiler/iface/MkIface.lhs          |    2 +-
 compiler/main/PprTyThing.hs         |    4 +-
 compiler/parser/Parser.y.pp         |   10 ++++++--
 compiler/typecheck/TcSplice.lhs     |   11 +++++----
 compiler/typecheck/TcTyClsDecls.lhs |   13 +++++++----
 9 files changed, 73 insertions(+), 44 deletions(-)

comment:2 Changed 15 months ago by simonpj

  • Difficulty set to Unknown
  • Resolution set to fixed
  • Status changed from new to closed
  • Test Case set to typecheck/should_compile/T7562

Good idea, thanks.

Note: See TracTickets for help on using tickets.