GNU bug report logs - #50588
[PATCH] import: cabal: Treat identifier names correctly.

Previous Next

Package: guix-patches;

Reported by: Xinglu Chen <public <at> yoctocell.xyz>

Date: Tue, 14 Sep 2021 18:43:02 UTC

Severity: normal

Tags: patch

Done: Lars-Dominik Braun <lars <at> 6xq.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 50588 in the body.
You can then email your comments to 50588 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#50588; Package guix-patches. (Tue, 14 Sep 2021 18:43:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Xinglu Chen <public <at> yoctocell.xyz>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Tue, 14 Sep 2021 18:43:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: guix-patches <at> gnu.org
Subject: [PATCH] import: cabal: Treat identifier names correctly.
Date: Tue, 14 Sep 2021 20:42:18 +0200
* guix/import/cabal.scm (is-id): Accept the location as an argument.  Don’t
check if the identifier name is a reserved keyword unless it is the first word
on the line.
(lex-word): Adjust accordingly.
* tests/hackage ("hackage->guix-package tests flag executable"): Expect it to
pass.

Fixes: <https://issues.guix.gnu.org/25138>
---
‘guix import hackage darcs’ now works correctly, and it fixes a
five year old bug.  :-)

--8<---------------cut here---------------start------------->8---
$ ./pre-inst-env guix import hackage darcs
(package
  (name "ghc-darcs")
  (version "2.16.4")
  (source
    (origin
      (method url-fetch)
      (uri (string-append
             "https://hackage.haskell.org/package/darcs/darcs-"
             version
             ".tar.gz"))
      (sha256
        (base32
          "07dygwh6p4fsrlgxmq6r7yvxmf4n2y04izzd30jzqgs0pi9645p4"))))
  (build-system haskell-build-system)
  (inputs
    `(("ghc-regex-compat-tdfa" ,ghc-regex-compat-tdfa)
      ("ghc-regex-applicative" ,ghc-regex-applicative)
      ("ghc-fgl" ,ghc-fgl)
      ("ghc-html" ,ghc-html)
      ("ghc-memory" ,ghc-memory)
      ("ghc-cryptonite" ,ghc-cryptonite)
      ("ghc-base16-bytestring" ,ghc-base16-bytestring)
      ("ghc-utf8-string" ,ghc-utf8-string)
      ("ghc-vector" ,ghc-vector)
      ("ghc-tar" ,ghc-tar)
      ("ghc-data-ordlist" ,ghc-data-ordlist)
      ("ghc-attoparsec" ,ghc-attoparsec)
      ("ghc-zip-archive" ,ghc-zip-archive)
      ("ghc-async" ,ghc-async)
      ("ghc-constraints" ,ghc-constraints)
      ("ghc-unix-compat" ,ghc-unix-compat)
      ("ghc-old-time" ,ghc-old-time)
      ("ghc-temporary" ,ghc-temporary)
      ("ghc-hashable" ,ghc-hashable)
      ("ghc-mmap" ,ghc-mmap)
      ("ghc-zlib" ,ghc-zlib)
      ("ghc-network-uri" ,ghc-network-uri)
      ("ghc-network" ,ghc-network)
      ("ghc-conduit" ,ghc-conduit)
      ("ghc-http-conduit" ,ghc-http-conduit)
      ("ghc-http-types" ,ghc-http-types)))
  (native-inputs
    `(("ghc-cmdargs" ,ghc-cmdargs)
      ("ghc-findbin" ,ghc-findbin)
      ("ghc-quickcheck" ,ghc-quickcheck)
      ("ghc-leancheck" ,ghc-leancheck)
      ("ghc-hunit" ,ghc-hunit)
      ("ghc-test-framework" ,ghc-test-framework)
      ("ghc-test-framework-hunit"
       ,ghc-test-framework-hunit)
      ("ghc-test-framework-quickcheck2"
       ,ghc-test-framework-quickcheck2)
      ("ghc-test-framework-leancheck"
       ,ghc-test-framework-leancheck)
      ("ghc-exceptions" ,ghc-exceptions)
      ("ghc-monad-control" ,ghc-monad-control)
      ("ghc-system-filepath" ,ghc-system-filepath)
      ("ghc-system-fileio" ,ghc-system-fileio)
      ("ghc-transformers-base" ,ghc-transformers-base)))
  (home-page "http://darcs.net/")
  (synopsis
    "a distributed, interactive, smart revision control system")
  (description
    "Darcs is a free, open source revision control system. It is: . * Distributed: Darcs was one of the first revision control systems in which every user has access to the full command set, removing boundaries between server and client or committer and non-committers. . * Interactive: Darcs is easy to learn and efficient to use because it asks you questions in response to simple commands, giving you choices in your work flow. You can choose to record one change in a file, while ignoring another. As you update from upstream, you can review each patch, picking and choosing which patches are appropriate. . * Smart: Darcs is different from most revision control systems in that it is based on the notion of change (or patch), rather than version. An underlying algebra of patches determines whether changes can be re-ordered. The laws of this algebra guarantee that the result of merging depends only on the final set of patches applied in a repository and not on their order. . * Simple: As a consequence, Darcs offers a conceptually simpler view of the state of a repository: it is given by the set of patches it contains. Pulling and pushing patches merely transfers them from one set to another. So called \"cherry-picking\" is the default mode of operation, and it fully preserves the identity of patches.")
  (license #f))
--8<---------------cut here---------------end--------------->8---
  
 guix/import/cabal.scm | 13 ++++++++++---
 tests/hackage.scm     |  2 --
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/guix/import/cabal.scm b/guix/import/cabal.scm
index e9a0179b3d..16e69b9cdd 100644
--- a/guix/import/cabal.scm
+++ b/guix/import/cabal.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2015 Federico Beffa <beffa <at> fbengineering.ch>
 ;;; Copyright © 2018 Ricardo Wurmus <rekado <at> elephly.net>
+;;; Copyright © 2021 Xinglu Chen <public <at> yoctocell.xyz>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -399,14 +400,20 @@ matching a string against the created regexp."
 
 (define (is-or s) (string=? s "||"))
 
-(define (is-id s port)
+(define (is-id s port loc)
   (let ((cabal-reserved-words
          '("if" "else" "library" "flag" "executable" "test-suite" "custom-setup"
            "source-repository" "benchmark" "common"))
         (spaces (read-while (cut char-set-contains? char-set:blank <>) port))
         (c (peek-char port)))
     (unread-string spaces port)
-    (and (every (cut string-ci<> s <>) cabal-reserved-words)
+    ;; Sometimes the name of an identifier is the same as one of the reserved
+    ;; words, which would normally lead to an error, see
+    ;; <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25138>.  Unless the word
+    ;; is at the beginning of a line (excluding whitespace), treat is as just
+    ;; another identifier instead of a reserved word.
+    (and (or (not (= (source-location-column loc) (current-indentation)))
+             (every (cut string-ci<> s <>) cabal-reserved-words))         
          (and (not (char=? (last (string->list s)) #\:))
               (not (char=? #\: c))))))
 
@@ -568,7 +575,7 @@ LOC is the current port location."
           ((is-none w) (lex-none loc))
           ((is-and w) (lex-and loc))
           ((is-or w) (lex-or loc))
-          ((is-id w port) (lex-id w loc))
+          ((is-id w port loc) (lex-id w loc))
           (else (unread-string w port) #f))))
 
 (define (lex-line port loc)
diff --git a/tests/hackage.scm b/tests/hackage.scm
index 53972fc643..aca807027c 100644
--- a/tests/hackage.scm
+++ b/tests/hackage.scm
@@ -318,8 +318,6 @@ executable cabal
     mtl        >= 2.0      && < 3
 ")
 
-;; Fails: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25138
-(test-expect-fail 1)
 (test-assert "hackage->guix-package test flag executable"
   (eval-test-with-cabal test-cabal-flag-executable match-ghc-foo))
 

base-commit: ec0e05ff306c950142c9ead7c712c749617069e7
-- 
2.33.0







Reply sent to Lars-Dominik Braun <lars <at> 6xq.net>:
You have taken responsibility. (Wed, 15 Sep 2021 12:33:02 GMT) Full text and rfc822 format available.

Notification sent to Xinglu Chen <public <at> yoctocell.xyz>:
bug acknowledged by developer. (Wed, 15 Sep 2021 12:33:02 GMT) Full text and rfc822 format available.

Message #10 received at 50588-done <at> debbugs.gnu.org (full text, mbox):

From: Lars-Dominik Braun <lars <at> 6xq.net>
To: Xinglu Chen <public <at> yoctocell.xyz>
Cc: 50588-done <at> debbugs.gnu.org
Subject: Re: [bug#50588] [PATCH] import: cabal: Treat identifier names
 correctly.
Date: Wed, 15 Sep 2021 14:32:03 +0200
Hi,

looks good, pushed as a840caccaee8c9492f4cc8a7ba802ef54391f199 with some
trailing whitespace removed.

Cheers,
Lars





Information forwarded to guix-patches <at> gnu.org:
bug#50588; Package guix-patches. (Wed, 15 Sep 2021 13:51:01 GMT) Full text and rfc822 format available.

Message #13 received at 50588 <at> debbugs.gnu.org (full text, mbox):

From: zimoun <zimon.toutoune <at> gmail.com>
To: Xinglu Chen <public <at> yoctocell.xyz>
Cc: 50588 <at> debbugs.gnu.org
Subject: Re: [bug#50588] [PATCH] import: cabal: Treat identifier names
 correctly.
Date: Wed, 15 Sep 2021 09:55:57 +0200
Hi,

On Tue, 14 Sept 2021 at 20:43, Xinglu Chen <public <at> yoctocell.xyz> wrote:

> * guix/import/cabal.scm (is-id): Accept the location as an argument.  Don’t
> check if the identifier name is a reserved keyword unless it is the first word
> on the line.
> (lex-word): Adjust accordingly.
> * tests/hackage ("hackage->guix-package tests flag executable"): Expect it to
> pass.
>
> Fixes: <https://issues.guix.gnu.org/25138>

Oh awesome!  Thanks!  Yesterday, I was reviewing old bugs and dig the
cabal parser was too intimidating. :-)

Cheers,
simon




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 14 Oct 2021 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 193 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.