Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC

Commits:

3 changed files:

Changes:

  • compiler/GHC/Types/Error.hs
    ... ... @@ -602,8 +602,14 @@ instance Diagnostic e => ToJson (MsgEnvelope e) where
    602 602
         where
    
    603 603
           diag = errMsgDiagnostic m
    
    604 604
           opts = defaultDiagnosticOpts @e
    
    605
    -      style = mkErrStyle (errMsgContext m)
    
    606
    -      ctx = defaultSDocContext {sdocStyle = style }
    
    605
    +      ctx = defaultSDocContext {
    
    606
    +          sdocStyle = mkErrStyle (errMsgContext m)
    
    607
    +        , sdocCanUseUnicode = True
    
    608
    +             -- Using Unicode makes it easier to consume the JSON output,
    
    609
    +             -- e.g. a suggestion to use foldl' will be displayed as
    
    610
    +             -- \u2018foldl'\u2019, which is not easily confused with
    
    611
    +             -- the quoted ‘foldl’ (note: no tick).
    
    612
    +        }
    
    607 613
           diagMsg = filter (not . isEmpty ctx) (unDecorated (diagnosticMessage (opts) diag))
    
    608 614
           renderToJSString :: SDoc -> JsonDoc
    
    609 615
           renderToJSString = JSString . (renderWithContext ctx)
    

  • testsuite/tests/driver/json.stderr
    1
    -{"version":"1.1","ghcVersion":"ghc-9.13.20241113","span":{"file":"json.hs","start":{"line":9,"column":11},"end":{"line":9,"column":21}},"severity":"Error","code":48010,"message":["Empty list of alternatives in case expression"],"hints":["Perhaps you intended to use the `EmptyCase' extension"]}
    1
    +{"version":"1.1","ghcVersion":"ghc-9.13.20250529","span":{"file":"json.hs","start":{"line":9,"column":11},"end":{"line":9,"column":21}},"severity":"Error","code":48010,"message":["Empty list of alternatives in case expression"],"hints":["Perhaps you intended to use the \u2018EmptyCase\u2019 extension"]}

  • testsuite/tests/driver/json_warn.stderr
    1
    -{"version":"1.1","ghcVersion":"ghc-9.13.20241113","span":{"file":"json_warn.hs","start":{"line":4,"column":3},"end":{"line":4,"column":4}},"severity":"Warning","code":40910,"message":["Defined but not used: `x'"],"hints":[],"reason":{"flags":["unused-matches"]}}
    
    2
    -{"version":"1.1","ghcVersion":"ghc-9.13.20241113","span":{"file":"json_warn.hs","start":{"line":7,"column":5},"end":{"line":7,"column":9}},"severity":"Warning","code":63394,"message":["In the use of `head'\n(imported from Prelude, but defined in GHC.Internal.List):\n\"This is a partial function, it throws an error on empty lists. Use pattern matching, 'Data.List.uncons' or 'Data.Maybe.listToMaybe' instead. Consider refactoring to use \"Data.List.NonEmpty\".\""],"hints":[],"reason":{"category":"x-partial"}}
    1
    +{"version":"1.1","ghcVersion":"ghc-9.13.20250529","span":{"file":"json_warn.hs","start":{"line":4,"column":3},"end":{"line":4,"column":4}},"severity":"Warning","code":40910,"message":["Defined but not used: \u2018x\u2019"],"hints":[],"reason":{"flags":["unused-matches"]}}
    
    2
    +{"version":"1.1","ghcVersion":"ghc-9.13.20250529","span":{"file":"json_warn.hs","start":{"line":7,"column":5},"end":{"line":7,"column":9}},"severity":"Warning","code":63394,"message":["In the use of \u2018head\u2019\n(imported from Prelude, but defined in GHC.Internal.List):\n\"This is a partial function, it throws an error on empty lists. Use pattern matching, 'Data.List.uncons' or 'Data.Maybe.listToMaybe' instead. Consider refactoring to use \"Data.List.NonEmpty\".\""],"hints":[],"reason":{"category":"x-partial"}}