Skip to content

Weird pattern matching bug #1259

Closed
Closed
@trizko

Description

@trizko

Both of these functions compile without errors:

toAction : Int -> Action
toAction x =
  case x of
    -1 -> Left
    1  -> Right
    _  -> NoOp

toAction : Int -> Action
toAction x =
  case x of
    1  -> Right
    (-1) -> Left
    _  -> NoOp

However, when I try to compile this code(using elm-reactor or elm-make initial-code/Spaceship.elm --output test.js):

toAction : Int -> Action
toAction x =
  case x of
    1  -> Right
    -1 -> Left
    _  -> NoOp

I get the following error:

Detected errors in 1 module.
-- SYNTAX PROBLEM ----------------------------------- initial-code/Spaceship.elm

I ran into something unexpected when parsing your code!

88│     -1 -> Left
           ^
I am looking for one of the following things:

    end of input
    whitespace

elm-package.json:

...
    "dependencies": {
        "elm-lang/core": "3.0.0 <= v < 4.0.0",
        "evancz/elm-html": "4.0.2 <= v < 5.0.0",
        "evancz/start-app": "2.0.2 <= v < 3.0.0"
    },
    "elm-version": "0.16.0 <= v < 0.17.0"
...

environment:

$ brew cask info elm-platform
elm-platform: 0.16
Elm
http://www.elm-lang.org
/opt/homebrew-cask/Caskroom/elm-platform/0.16 (23M)
https://github.com/caskroom/homebrew-cask/blob/master/Casks/elm-platform.rb
==> Contents
  Elm-Platform-0.16.pkg (pkg)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions