"Alan & Kim Zimmerman" <alan.z...@gmail.com> writes:

> I am working through some ghc-exactprint test cases with GHC 9.2.1 and came
> across an oddity.
>
> If I parse some source with
>
> {-# LINE 93 "Foo.chs" #-}
>
> on line five, it shows up in the ParseSource as
>
> (L
>   (Anchor
>    { LINE:5:1-25 }
>    (UnchangedAnchor))
>   (EpaComment
>    (EpaLineComment
>     "{-# LINE 93 \"Foo.chs\" #-}")
>    { LINE:5:1-25 }))
>
> and the following item locations are unchanged.
>
> The effect seems to be to change the name of the file in the RealSrcSpan to
> "LINE", but just for that line, and no other effect.
>
> Is this expected?
>
It sounds wrong to me, although it is surprising that there aren't any
tests covering this.

A quick search of the lexer reveals that GHC.Parser.Lexer.mkParserOpts
takes an argument which dictates whether LINE and COLUMN pragmas update
the lexer's source location or are instead just emitted in the lexeme
stream.

That being said, `GHC.Driver.Config.Parser.initParserOpts` seems to pass
`True` here, which should update the source location.

Were you testing with GHC or are you using the GHC API?

Cheers,

- Ben

Attachment: signature.asc
Description: PGP signature

_______________________________________________
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

Reply via email to