@@ -10,7 +10,6 @@ module Ormolu.Printer.Meat.Declaration.Value
1010 )
1111where
1212
13−import Ormolu.Printer.Internal
1413import Bag (bagToList)
1514import BasicTypes
1615import Control.Monad
@@ -847,7 +846,12 @@ p_hsSpliceTH isTyped expr = \case
847846
848847p_hsBracket :: HsBracket GhcPs -> R ()
849848p_hsBracket = \case
850− ExpBr NoExt expr -> quote "e" (located expr p_hsExpr)
849+ ExpBr NoExt expr -> do
850+ anns <- getEnclosingAnns
851+ let name = case anns of
852+ AnnOpenEQ:_ -> ""
853+ _ -> "e"
854+ quote name (located expr p_hsExpr)
851855 PatBr NoExt pat -> quote "p" (located pat p_pat)
852856 DecBrL NoExt decls -> quote "d" (p_hsDecls Free decls)
853857 DecBrG NoExt _ -> notImplemented "DecBrG" -- result of renamer
@@ -967,3 +971,12 @@ withGuards = any (checkOne . unLoc)
967971 checkOne :: GRHS GhcPs (Located body) -> Bool
968972 checkOne (GRHS NoExt [] _) = False
969973 checkOne _ = True
974+
975+-- | Get annotations for the enclosing element.
976+
977+getEnclosingAnns :: R [AnnKeywordId]
978+getEnclosingAnns = do
979+ e <- getEnclosingSpan (const True)
980+ case e of
981+ Nothing -> return []
982+ Just e' -> getAnns (RealSrcSpan e')