Opened 3 years ago

Closed 3 years ago

#10209 closed bug (fixed)

parser: opt_kind_sig has incorrect SrcSpan

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

Description

The production for opt_kind_sig is

opt_kind_sig :: { Located (Maybe (LHsKind RdrName)) }
        :                             { noLoc Nothing }
        | '::' kind                   {% ajl (sLL $1 $> (Just $2)) AnnDcolon (gl $1) }

The outer Location is used only to get the full span for the enclosing declration, and is then stripped. The inner LHsKind then has a SrcSpan that does not include the '::'

Extend the SrcSpan on $2 to include $1

Change History (12)

comment:1 Changed 3 years ago by alanz

It may be necessary to change

type HsKind name = HsType name
type HsKind name = LHsType name

So that the '::' can be annotated separately from the kind. Otherwise we have a problem for

HsTyVar name

where we have been using the surrounding span for the annotation.

comment:2 Changed 3 years ago by alanz

Milestone: 7.10.2

comment:3 Changed 3 years ago by alanz

Differential Rev(s): Phab:D813
Status: newpatch

comment:4 Changed 3 years ago by alanz

Owner: alanz deleted
Status: patchnew

comment:5 Changed 3 years ago by alanz

Owner: set to alanz

comment:6 Changed 3 years ago by alanz

From ezyang

...but the LHsKind shouldn't include the ::, right? Because that's not part of the kind.

Proposed fix: pass the AnnDcolon up to whatever contains the opt_kind_sig.

comment:7 Changed 3 years ago by jstolarek

My two cents: this part of the parser will be touched by Phab:D202 once it is merged.

comment:8 Changed 3 years ago by alanz

Status: newpatch

comment:9 Changed 3 years ago by Austin Seipp <austin@…>

In 8aefc9b746512e91891879ad546e850e8a427d23/ghc:

parser: opt_kind_sig has incorrect SrcSpan

The production for opt_kind_sig is

  opt_kind_sig :: { Located (Maybe (LHsKind RdrName)) }
          :                             { noLoc Nothing }
          | '::' kind                   {% ajl (sLL $1 $> (Just $2)) AnnDcolon (gl $1) }

The outer Location is used only to get the full span for the enclosing
declration, and is then stripped. The inner LHsKind then has a SrcSpan that does
not include the '::'

Extend the SrcSpan on $2 to include $1

Reviewed By: austin

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

GHC Trac Issues: #10209

comment:10 Changed 3 years ago by ezyang

Resolution: fixed
Status: patchclosed

comment:11 Changed 3 years ago by alanz

Status: closedmerge

comment:12 Changed 3 years ago by thoughtpolice

Status: mergeclosed

Merged to ghc-7.10.

Note: See TracTickets for help on using tickets.