Elm Exactly
Results / elm-parser /

ParserIssue25IntCommitsOnLeadingETest

Tags:elm19-bug

elm-0.19.1 failelm-0.19.2 failelm-0.19.3 faillamdera-1.5.0 fail

Issue: elm/parser#25

`Parser.int` consumes input that starts with the letter `e`, so `oneOf` cannot try the next
alternative.

<https://github.com/elm/parser/issues/25>

`oneOf [ int, letters ]` on "else" fails with ExpectingInt in Elm 0.19.1 (elm/parser 1.1.0): `int`
treats the `e` as the start of an exponent and fails after chomping. Input without a digit is not
a number, so `int` must fail without consuming and `oneOf` must use the second parser.

Results

elm-0.19.1

failran in 72 ms
Missing pattern: result: Ok "else"
--- output ---
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
result: Err [{ col = 2, problem = ExpectingInt, row = 1 }]

elm-0.19.2

failran in 63 ms
Missing pattern: result: Ok "else"
--- output ---
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
result: Err [{ col = 2, problem = ExpectingInt, row = 1 }]

elm-0.19.3

failran in 52 ms
Missing pattern: result: Ok "else"
--- output ---
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
result: Err [{ col = 2, row = 1, problem = ExpectingInt }]

lamdera-1.5.0

failran in 39 ms
Missing pattern: result: Ok "else"
--- output ---
result: Err [{ col = 2, row = 1, problem = ExpectingInt }]

Discussions

Discuss this test·Search the discussions on GitHub

Discussions are on GitHub; one about this test has [t:elm-parser/ParserIssue25IntCommitsOnLeadingETest] in its title.

Source

The -- CHECK: lines give the expected output.

module ParserIssue25IntCommitsOnLeadingETest exposing (main)
{-| `Parser.int` consumes input that starts with the letter `e`, so `oneOf` cannot try the next
alternative.
<https://github.com/elm/parser/issues/25>
`oneOf [ int, letters ]` on "else" fails with ExpectingInt in Elm 0.19.1 (elm/parser 1.1.0): `int`
treats the `e` as the start of an exponent and fails after chomping. Input without a digit is not
a number, so `int` must fail without consuming and `oneOf` must use the second parser.
-}
-- TAGS: elm19-bug
-- CHECK: result: Ok "else"
import Html exposing (text)
import Parser
main =
let
intOrWord =
Parser.oneOf
[ Parser.map String.fromInt Parser.int
, Parser.getChompedString (Parser.chompWhile Char.isAlpha)
]
_ =
Debug.log "result" (Parser.run intOrWord "else")
in
text "done"