Skip to content

Line trailing comments not stripped #2681

Closed

Description

@phadej

issue with accelerate-cuda 0.14.0.0 file: https://gist.github.com/phadej/641d82190cdd0400fc28

Original:

Extra-tmp-files:        config.status
                        config.log
                        autom4te.cache
                        accelerate-cuda.buildinfo               -- generated by configure

Formatted:

extra-tmp-files:
    config.status
    config.log
    autom4te.cache
    accelerate-cuda.buildinfo
    --
    generated
    by
    configure

I'm not sure if the issue is in the parser or prettyprinter


related to: #2460 #2607

Activity

  1. phadej commented on Jun 25, 2015

    @phadej
    CollaboratorAuthor

    Test case in phadej@836d414

  2. BardurArantsson commented on Jun 25, 2015

    @BardurArantsson
    Collaborator

    This issue desperately needs a description of what the actual problem is, i.e. what did you do and what did you expect to happen? What did happen?

  3. 23Skidoo commented on Jun 25, 2015

    @23Skidoo
    Member

    This issue desperately needs a description of what the actual problem is, i.e. what did you do and what did you expect to happen?

    He took accelerate-cuda-0.14.0.0.cabal and ran it through cabal format. See #2607 (comment).

  4. BardurArantsson commented on Jun 25, 2015

    @BardurArantsson
    Collaborator

    Yes, I can see that, but this is still not a useful issue description if a reader of the issue has to trawl through comments in a different issue/PR to figure out what's going on. (Esp. since the PR is still open.)

    EDIT: grammer

  5. lspitzner commented on Jun 25, 2015

    @lspitzner
    Collaborator

    @BardurArantsson without any deeper knowledge about the subject, here is my guess what is meant:

    -- generated by configure is a comment. it is not kept intact by a parse/pretty-print round-trip.

    the expected behaviour is that
    a) the output contains the complete comment -- generated by configure
    b) most importantly: there are not three new extra-temp-files, namely "generated" "by" and "configure"

  6. BardurArantsson commented on Jun 25, 2015

    @BardurArantsson
    Collaborator

    Ok, that's a more useful description. It shouldn't be necessary to guess, however since it would take all of 5 minutes for the reporter to write that :).

    ( @phadej : I promise, I'm not trying to single you out specifically (... at length). I'm just making the point that for issue descriptions to be useful they must be understandable by people who aren't involved in the original issues, etc. IOW understandable on their own. You just happened to provide an example. :))

  7. changed the title [-]cabal format outputs comments?[/-] [+]Line trailing comments not stripped[/+] on Jun 26, 2015
  8. phadej commented on Jun 26, 2015

    @phadej
    CollaboratorAuthor

    I investigated this further. The problem is in the parser, it doesn't strip -- trailing line comments.
    For example cabal file with

    license: BSD3 -- or should we have GPL?
    

    will fail to parse, which is ok.

    But list fields (like extra-source-files) will be parsed so comment as treated as real content:

    extra-src-files: README.md -- foobar
    

    into

    extraSrcFiles = ["README.md","--","foobar"],

    There is trimLines in Cabal.Distribution.ParseUtils which strips whole line comments, but it cannot be extended as context is important. Eg. we would like to have

    cc-options: --my-special-compiler-option
    

    Hacky soluton A:

    I could make abit hacky solution to strip WS+ DASH DASH WS+ (not DOUBLEQUOTE)* from the end of the lines in trimLines.


    Real solution B: would be to take @dcoutts parsec parser into use, but it is blocked by ghc-the-library dependency on Cabal. I could help with decoupling, if there are some pointers.

  9. phadej commented on Aug 15, 2017

    @phadej
    CollaboratorAuthor

    Update. This is by design. The frame syntax of .cabal like files doesn't accept end-of-line comments.

    I'm not sure how to proceed. Some warning would be useful. Maybe warn about, --files, and suggest using "--files" in some fields (files, and modules, build-depends?)

    ping @hvr

  10. self-assigned this
    on Dec 16, 2017
  11. added this to the 2.2 milestone on Dec 16, 2017
  12. added 3 commits that reference this issue on Dec 24, 2017
    a0c12cd
    0223f6a
    93a2171
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions