Opened 3 years ago

Closed 3 years ago

#6139 closed bug (invalid)

Data.Time.Day read instance too liberal

Reported by: guest Owned by:
Priority: normal Milestone:
Component: libraries/base Version: 7.0.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect result at runtime Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

Prelude Data.Time> read "0001-22-01" :: Day 0001-12-01

Obviously, this should be a parse error.

Change History (4)

comment:1 Changed 3 years ago by guest

(forgot to sign: sonoflilit at gmail)

comment:2 Changed 3 years ago by altaic

This looks to be fixed in 7.4.1:

$ ghci
GHCi, version 7.4.1: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> :module Data.Time
Prelude Data.Time> read "0001-22-01" :: Day 0001-12-01

<interactive>:3:26: parse error on input `0001'

as well as in git master:

$ ./inplace/bin/ghc-stage2 --interactive
GHCi, version 7.5.20120602: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> :module Data.Time
Prelude Data.Time> read "0001-22-01" :: Day 0001-12-01

<interactive>:3:26:
    Illegal literal in type (use -XDataKinds to enable): 1

comment:3 Changed 3 years ago by guest

No, it's

Prelude Data.Time> read "0001-22-01" :: Day
0001-12-01

Faulty month 22 is parsed as 12.

comment:4 Changed 3 years ago by igloo

  • difficulty set to Unknown
  • Resolution set to invalid
  • Status changed from new to closed

Thanks for the report, but please send bugs in the time library to the author ([email protected]).

Note: See TracTickets for help on using tickets.