ndmitchell / hlint

Haskell source code suggestions
Other
1.45k stars 194 forks source link

Incorrect redundant backet suggestion with `BlockArguments` and operator sections #1573

Open pnotequalnp opened 4 months ago

pnotequalnp commented 4 months ago

When the operand of a left operator section is an application with the argument a lambda taking advantage of BlockArguments, an incorrect suggestion to remove the brackets around the application is given. Removal of these brackets would move the operator inside the lambda, resulting in a syntax error.

Example module:

{-# LANGUAGE BlockArguments #-}

module Example where

f = ((const 1 \_ -> ()) +)

Emitted suggestion:

Example.hs:5:6-23: Suggestion: Redundant bracket
Found:
  ((const 1 \ _ -> ()) +)
Perhaps:
  (const 1 \ _ -> () +)

Module after accepting the suggestion (syntax error):

{-# LANGUAGE BlockArguments #-}

module Example where

f = (const 1 \_ -> () +)