faylang / fay

A proper subset of Haskell that compiles to JavaScript
https://github.com/faylang/fay/wiki
BSD 3-Clause "New" or "Revised" License
1.29k stars 86 forks source link

Pattern match failure for newtypes #431

Closed henrylaxen closed 9 years ago

henrylaxen commented 9 years ago

Hi again Adam,

While trying to compile this:


module Main where import Prelude

newtype I = I Int -- this fails with: -- fay: user error -- (Pattern match failure in do expression at src/Fay/Compiler/Decl.hs:101:7-20)

-- data I = I Int -- this compiles

test :: I -> Fay ()
test x = do let I i = x return ()module Main where import Prelude

newtype I = I Int -- this fails with: -- fay: user error -- (Pattern match failure in do expression at src/Fay/Compiler/Decl.hs:101:7-20)

-- data I = I Int -- this compiles

test :: I -> Fay ()
test x = do let I i = x return ()


I get a compiler error. A workaround is using data instead of newtype. Thought you should know.

Best wishes, Henry Laxen

henrylaxen commented 9 years ago

Messed up the formatting, sorry.

module Main where
import Prelude

newtype I = I Int    -- this fails with:
                     -- fay: user error
                     -- (Pattern match failure in do expression at src/Fay/Compiler/Decl.hs:101:7-20)

-- data I = I Int    -- this compiles

test :: I -> Fay ()        
test x = do
  let
    I i = x
  return ()
bergmark commented 9 years ago

Very hacky fix, but it works! Released as fay-0.23.1.1

Thanks for the report!