Opened 3 years ago

Closed 3 years ago

#10092 closed bug (invalid)

lex doesn't handle binary literals

Reported by: RyanGlScott Owned by: ekmett
Priority: normal Milestone:
Component: Core Libraries Version: 7.10.1-rc2
Keywords: BinaryLiterals report-impact Cc: hvr, ekmett, core-libraries-committee@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect result at runtime Test Case:
Blocked By: Blocking:
Related Tickets: #9224 Differential Rev(s):
Wiki Page:

Description

The lex function from Text.Read.Lex (on which the Read instance for Lexeme is based) can't read binary literals on GHC 7.10.1-rc2:

$ ghci -XBinaryLiterals
GHCi, version 7.10.0.20150123: http://www.haskell.org/ghc/  :? for help
λ> 0b101010
42
λ> import Text.Read.Lex
λ> read "0b101010" :: Lexeme
*** Exception: Prelude.read: no parse

This should be a simple fix, but I'm not sure if this is the intended behavior or not, since BinaryLiterals isn't a part of the Haskell 2010 standard (and I'm not sure how closely lex adheres to that).

Change History (4)

comment:1 Changed 3 years ago by hvr

Cc: core-libraries-committee@… added
Component: libraries/baseCore Libraries
Keywords: BinaryLiterals report-impact added
Owner: set to ekmett

comment:2 Changed 3 years ago by ekmett

Given that read and show should have portable behavior across implementations, it seems to me that we should _not_ support binary literals in read/lex.

Otherwise we invite the endless waves of portability problems that ensue from the "be liberal in what you accept, strict in what you output" dogma.

comment:3 Changed 3 years ago by RyanGlScott

I'm OK with that, I just wanted to confirm that lex was in fact meant to adhere to a portable implementation.

comment:4 Changed 3 years ago by RyanGlScott

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.