Skip to content

guard may evaluate to false, but _ case present #271

@mabre

Description

@mabre

The following code runs fine with ghc (printing Nothing):

module WhereGuardBug where

readDriveShare :: [Char] -> Maybe ([Char], [Char])
readDriveShare (x:xs) | x == '/' = Just (x:a,b)
    where (a,b) = (['f'],['g'])
readDriveShare _ = Nothing

main = print $ readDriveShare ('f':'i':'l':'e':[])

When compiling with frege, I get

W whereGuardBug.hs:4: guard (== x '/') may evaluate to false.

and at runtime

Exception in thread "main" frege.runtime.NoMatch: readDriveShare at line 4 no match for value frege.prelude.PreludeBase$TTuple2@70177ecd
        at WhereGuardBug.readDriveShare(WhereGuardBug.java:90)
        at WhereGuardBug.lambda$null$2(WhereGuardBug.java:135)
        at frege.run8.Thunk.call(Thunk.java:231)
        at WhereGuardBug.lambda$null$0(WhereGuardBug.java:127)
        at frege.run8.Thunk.call(Thunk.java:231)
        at WhereGuardBug.lambda$static$3(WhereGuardBug.java:153)
        at frege.run8.Thunk.call(Thunk.java:231)
        at WhereGuardBug.main(WhereGuardBug.java:162)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions