Opened 3 years ago

Closed 2 years ago

Last modified 2 years ago

#10313 closed bug (fixed)

ApiAnnotations : strings in warnings do not return SourceText

Reported by: alanz Owned by: alanz
Priority: normal Milestone: 8.0.1
Component: Compiler Version: 7.10.1
Keywords: ApiAnnotations Cc: mpickering
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D907
Wiki Page:

Description

The strings used in a WARNING pragma are captured via

strings :: { Located ([AddAnn],[Located FastString]) }
    : STRING { sL1 $1 ([],[L (gl $1) (getSTRING $1)]) }
..

The STRING token has a method getSTRINGs that returns the original source text for a string.

A warning of the form

{-# WARNING Logic
          , mkSolver
          , mkSimpleSolver
          , mkSolverForLogic
          , solverSetParams
          , solverPush
          , solverPop
          , solverReset
          , solverGetNumScopes
          , solverAssertCnstr
          , solverAssertAndTrack
          , solverCheck
          , solverCheckAndGetModel
          , solverGetReasonUnknown
          "New Z3 API support is still incomplete and fragile: \
          \you may experience segmentation faults!"
  #-}

returns the concatenated warning string rather than the original source.

Change History (7)

comment:1 Changed 3 years ago by alanz

Milestone: 7.12.1

comment:2 Changed 3 years ago by alanz

Differential Rev(s): Phab:D907
Milestone: 7.12.17.10.2

I have set the milestone to 7.10.2, as this is the last item blocking a full hackage round trip, resulting in 40 or so failing files out of around 50k.

It does require a tiny change to Haddock, but is basically just adding SourceText fields to the last places they are required.

comment:3 Changed 3 years ago by alanz

Status: newpatch

comment:4 Changed 2 years ago by Alan Zimmerman <alan.zimm@…>

In e6191d1cc37e98785af8b309100ea840084fa3ba/ghc:

ApiAnnotations : strings in warnings do not return SourceText

Summary:
The strings used in a WARNING pragma are captured via

    strings :: { Located ([AddAnn],[Located FastString]) }
        : STRING { sL1 $1 ([],[L (gl $1) (getSTRING $1)]) }
    ..

The STRING token has a method getSTRINGs that returns the original
source text for a string.

A warning of the form

    {-# WARNING Logic
              , mkSolver
              , mkSimpleSolver
              , mkSolverForLogic
              , solverSetParams
              , solverPush
              , solverPop
              , solverReset
              , solverGetNumScopes
              , solverAssertCnstr
              , solverAssertAndTrack
              , solverCheck
              , solverCheckAndGetModel
              , solverGetReasonUnknown
              "New Z3 API support is still incomplete and fragile: \
              \you may experience segmentation faults!"
      #-}

returns the concatenated warning string rather than the original source.

This patch now deals with all remaining instances of getSTRING to bring
in a SourceText for each.

This updates the haddock submodule as well, for the AST change.

Test Plan: ./validate

Reviewers: hvr, austin, goldfire

Reviewed By: austin

Subscribers: bgamari, thomie, mpickering

Differential Revision: https://phabricator.haskell.org/D907

GHC Trac Issues: #10313

comment:5 Changed 2 years ago by thoughtpolice

Milestone: 7.10.27.12.1
Resolution: fixed
Status: patchclosed

This one won't be part of ghc-7.10, in order to keep API clients happy.

comment:6 Changed 2 years ago by Sergei Trofimovich <siarheit@…>

In b04bed0a/ghc:

renamer: fix module-level deprecation message

Noticed today that deprecation warnings are
slightly broken in -HEAD:

  mtl-2.2.1/Control/Monad/Error/Class.hs:46:1: warning:
    Module ‘Control.Monad.Trans.Error’ is deprecated:
      ([", U, s, e,  , C, o, n, t, r, o, l, ., M, o, n, a, d, ., T, r, a,
        n, s, ., E, x, c, e, p, t,  , i, n, s, t, e, a, d, "],
       Use Control.Monad.Trans.Except instead)

Commit e6191d1cc37e98785af8b309100ea840084fa3ba
slightly changed WarningTxt declaration:

-data WarningTxt = WarningTxt (Located SourceText) [Located FastString]
-                | DeprecatedTxt (Located SourceText) [Located FastString]
+data WarningTxt = WarningTxt (Located SourceText)
+                             [Located (SourceText,FastString)]
+                | DeprecatedTxt (Located SourceText)
+                                [Located (SourceText,FastString)]

But 'moduleWarn' function was not updated to do the stripping.

Signed-off-by: Sergei Trofimovich <siarheit@google.com>

Reviewers: austin, bgamari, hvr, goldfire, rwbarton, alanz

Reviewed By: rwbarton, alanz

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D1096

GHC Trac Issues: #10313

comment:7 Changed 2 years ago by thoughtpolice

Milestone: 7.12.18.0.1

Milestone renamed

Note: See TracTickets for help on using tickets.