- ptext SLIT("in the same infix expression")])
-
-sectionPrecErr op arg_op section
- = vcat [ptext SLIT("The operator") <+> ppr_opfix op <+> ptext SLIT("of a section"),
- nest 4 (ptext SLIT("must have lower precedence than the operand") <+> ppr_opfix arg_op),
- nest 4 (ptext SLIT("in the section:") <+> quotes (ppr section))]
-
-pp_prefix_minus = ptext SLIT("prefix `-'")
-ppr_op op = quotes (ppr op) -- Here, op can be a Name or a (Var n), where n is a Name
-ppr_opfix (pp_op, fixity) = pp_op <+> brackets (ppr fixity)
+ ptext (sLit "in the same infix expression")])
+
+sectionPrecErr :: (Name, Fixity) -> (Name, Fixity) -> HsExpr RdrName -> RnM ()
+sectionPrecErr op@(n1,_) arg_op@(n2,_) section
+ | isUnboundName n1 || isUnboundName n2
+ = return () -- Avoid error cascade
+ | otherwise
+ = addErr $ vcat [ptext (sLit "The operator") <+> ppr_opfix op <+> ptext (sLit "of a section"),
+ nest 4 (sep [ptext (sLit "must have lower precedence than that of the operand,"),
+ nest 2 (ptext (sLit "namely") <+> ppr_opfix arg_op)]),
+ nest 4 (ptext (sLit "in the section:") <+> quotes (ppr section))]
+
+ppr_opfix :: (Name, Fixity) -> SDoc
+ppr_opfix (op, fixity) = pp_op <+> brackets (ppr fixity)
+ where
+ pp_op | op == negateName = ptext (sLit "prefix `-'")
+ | otherwise = quotes (ppr op)