Skip to content

Cannot format operators starting with a hash when using UnboxedSums or UnboxedTuples #1062

@wismill

Description

@wismill

Describe the bug
Ormolu formats ( #<| ) as (#<|) when -XUnboxedSums or -XUnboxedTuples is set, thus the formatted code generates a parser error. I think it applies to any operator starting with #.

To Reproduce

Format the following file with --unsafe (else it fails).

{-# LANGUAGE UnboxedTuples #-}

module Foo (( #<| )) where

( #<| ) :: Int -> Int -> Int
( #<| ) = (+)

The generated code does not compile.

Expected behavior
Ormolu should keep the spaces to be valid code, i.e. ( #<| ) should be unchanged.

Environment

  • OS name + version: Linux (openSUSE Tumbleweed 20230828)
  • Version of the code: ormolu 0.7.1.0 using ghc-lib-parser 9.6.2.20230523

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions