-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect reduction of pattern matching #346
Comments
The following definition makes the program work as expected again. (.<=.) : Int -> Int -> Bool
0 .<=. _ = True
_ .<=. _ = False |
I can manually lift the case expression. foo : (Int, Int) -> Bool
foo (0, _) = True
foo _ = False
infix 3 .<=.
(.<=.) : Int -> Int -> Bool
(.<=.) p q = foo (p, q) Then Compile time tree:
case {arg:0}[0] : [__] of
{ Builtin.MkPair {e:0} {e:1} {e:2} {e:3}
=> case {e:2}[2] : [__] of
{ 0 => Prelude.True
| _ => Prelude.False
}
| _ => Prelude.False
} The generated case tree has a default branch, even though it's not necessary. Indeed, the default branch does seem to get in the way because if I change the second clause of I wonder if the evaluator somehow mistakenly concludes |
-- Default case matches against any *concrete* value
tryAlt env loc opts fc stk val (DefaultCase sc) def
= if concrete val
then evalTree env loc opts fc stk sc def
else def
where
concrete : NF free -> Bool
concrete (NDCon _ _ _ _ _) = True
concrete (NTCon _ _ _ _ _) = True
concrete (NPrimVal _ _) = True
concrete (NBind _ _ _ _) = True
concrete (NType _) = True
concrete _ = False I'll try marking only |
Changing the definition of concrete : NF free -> Bool
concrete (NDCon _ _ _ _ _) = True
concrete (NTCon _ _ _ _ _) = True
concrete (NPrimVal _ _) = True
concrete (NBind _ _ (Lam _ _ _) _) = True
concrete (NBind _ _ (Pi _ _ _) _) = True
concrete (NType _) = True
concrete _ = False |
Steps to Reproduce
Expected Behavior
The function
eraseVar
should fail to check on the RHS of its second-to-last clause.The correct RHS,
eraseVar thr xs i
, should check.Observed Behavior
The program checks and Idris claims that
Just (FS FZ) : Maybe (Fin 1)
.The correct RHS,
eraseVar thr xs i
, does not check.Other observations
Somehow the definition of
.<=.
is crucial to this problem. If I use just<=
from Prelude in thewith
expressions, everything works as expected.The text was updated successfully, but these errors were encountered: