Commit 2d953a60 authored by Chaitanya Koparkar's avatar Chaitanya Koparkar Committed by Krzysztof Gogolewski

Fix #10859 by using foldr1 while deriving Eq instances

Previously, we were using foldl1 instead, which led to the derived
code to be wrongly associated.

Test Plan: ./validate

Reviewers: RyanGlScott, nomeata, simonpj, bgamari

Reviewed By: RyanGlScott, nomeata

Subscribers: rwbarton, carter

GHC Trac Issues: #10859

Differential Revision:
parent 6e765aeb
......@@ -214,7 +214,9 @@ gen_Eq_binds loc tycon = do
nested_eq_expr [] [] [] = true_Expr
nested_eq_expr tys as bs
= foldl1 and_Expr (zipWith3Equal "nested_eq" nested_eq tys as bs)
= foldr1 and_Expr (zipWith3Equal "nested_eq" nested_eq tys as bs)
-- Using 'foldr1' here ensures that the derived code is correctly
-- associated. See Trac #10859.
nested_eq ty a b = nlHsPar (eq_Expr tycon ty (nlHsVar a) (nlHsVar b))
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment