diff --git a/frontend/tests/cases/positive/simple/case2.gr b/frontend/tests/cases/positive/simple/case2.gr new file mode 100644 index 000000000..aa279a324 --- /dev/null +++ b/frontend/tests/cases/positive/simple/case2.gr @@ -0,0 +1,11 @@ +caser : Int -> Int +caser n = case n of + 0 -> 2; + 1 -> 3; + 2 -> 5; + 5 -> 7; + 3 -> 11; + n -> n + +main : Int +main = caser 0 * caser 1 * caser 2 * caser 3 * caser 4 * caser 5 * caser 6 \ No newline at end of file diff --git a/frontend/tests/cases/positive/simple/case2.gr.output b/frontend/tests/cases/positive/simple/case2.gr.output new file mode 100644 index 000000000..3c0fee404 --- /dev/null +++ b/frontend/tests/cases/positive/simple/case2.gr.output @@ -0,0 +1 @@ +55440 \ No newline at end of file diff --git a/interpreter/src/Language/Granule/Interpreter/Eval.hs b/interpreter/src/Language/Granule/Interpreter/Eval.hs index 4e76f9693..02f41047b 100755 --- a/interpreter/src/Language/Granule/Interpreter/Eval.hs +++ b/interpreter/src/Language/Granule/Interpreter/Eval.hs @@ -660,15 +660,15 @@ pmatchCBV ctxt ((PBox _ _ _ p, e):ps) v@(Val _ _ _ (Promote _ v')) = do Just e -> return $ Just e Nothing -> pmatchCBV ctxt ps v -pmatchCBV ctxt ((PInt _ _ _ n, e):ps) (Val _ _ _ (NumInt m)) = +pmatchCBV ctxt ((PInt _ _ _ n, e):ps) v@(Val _ _ _ (NumInt m)) = if n == m then return $ Just e - else pmatchCBV ctxt ps e + else pmatchCBV ctxt ps v -pmatchCBV ctxt ((PFloat _ _ _ n, e):ps) (Val _ _ _ (NumFloat m)) = +pmatchCBV ctxt ((PFloat _ _ _ n, e):ps) v@(Val _ _ _ (NumFloat m)) = if n == m then return $ Just e - else pmatchCBV ctxt ps e + else pmatchCBV ctxt ps v pmatchCBV ctxt (_:ps) v = pmatchCBV ctxt ps v