Commit 07cc6039 authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

Don't crash when pretty-printing bad joins

Trac #15108 showed that the Core pretty-printer would
crash if it found a join-point binding with too few lambda
on the RHS.  That is super-unhelpful!  Lint will find it,
but pretty-printing should not crash.

This patch just makes the pretty printer behave more robustly;
it leaves the job of error reporting to Lint.
parent 4e45ebee
......@@ -128,10 +128,18 @@ ppr_binding ann (val_bdr, expr)
-- lambda (the first rendering looks like a nullary join point returning
-- an n-argument function).
pp_join_bind join_arity
| bndrs `lengthAtLeast` join_arity
= hang (ppr val_bdr <+> sep (map (pprBndr LambdaBind) lhs_bndrs))
2 (equals <+> pprCoreExpr rhs)
| otherwise -- Yikes! A join-binding with too few lambda
-- Lint will complain, but we don't want to crash
-- the pretty-printer else we can't see what's wrong
-- So refer to printing j = e
= pp_normal_bind
where
(lhs_bndrs, rhs) = collectNBinders join_arity expr
(bndrs, body) = collectBinders expr
lhs_bndrs = take join_arity bndrs
rhs = mkLams (drop join_arity bndrs) body
pprParendExpr expr = ppr_expr parens expr
pprCoreExpr expr = ppr_expr noParens expr
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment