From unknown Sat Jun 14 19:12:45 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#50588] [PATCH] import: cabal: Treat identifier names correctly. Resent-From: Xinglu Chen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 14 Sep 2021 18:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 50588 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 50588@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.163164495829367 (code B ref -1); Tue, 14 Sep 2021 18:43:02 +0000 Received: (at submit) by debbugs.gnu.org; 14 Sep 2021 18:42:38 +0000 Received: from localhost ([127.0.0.1]:50170 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mQDO4-0007dV-He for submit@debbugs.gnu.org; Tue, 14 Sep 2021 14:42:38 -0400 Received: from lists.gnu.org ([209.51.188.17]:51626) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mQDO2-0007dN-Mp for submit@debbugs.gnu.org; Tue, 14 Sep 2021 14:42:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59874) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQDO1-0004Qe-CA for guix-patches@gnu.org; Tue, 14 Sep 2021 14:42:30 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:51212 helo=mail.yoctocell.xyz) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQDNz-000736-1Z for guix-patches@gnu.org; Tue, 14 Sep 2021 14:42:29 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1631644939; bh=BlowU9At9lSp4te1i30eWukhCDhQYk3Z0IS4wdlQJ8s=; h=From:To:Subject:Date; b=fFVcKKIw9g7PlzTN1WS1y12F7aeMJHy2QGnxMwfleXFEOeTDrdAlzU3KxRluqKyT9 lz7ZG4vt85zxmrk0iv0/JkO+fF2x7w8MvXao8Z3EbUUOPRfNxHBM6MjYMiI8LnxYpM ey2OCZaUJo/7U6DKo3zO0eadQLX69Qp8jYqNwhS4= Message-Id: Date: Tue, 14 Sep 2021 20:42:18 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=87.96.130.155; envelope-from=public@yoctocell.xyz; helo=mail.yoctocell.xyz X-Spam_score_int: 34 X-Spam_score: 3.4 X-Spam_bar: +++ X-Spam_report: (3.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.499, FROM_SUSPICIOUS_NTLD_FP=1.999, PDS_OTHER_BAD_TLD=1.999, RDNS_DYNAMIC=0.982, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.7 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * guix/import/cabal.scm (is-id): Accept the location as an argument. =?UTF-8?Q?Don=E2=80=99t?= check if the identifier name is a reserved keyword unless it is the first word on the line. (lex-word): Adjust accordingly. [...] Content analysis details: (1.7 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [209.51.188.17 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.51.188.17 listed in wl.mailspike.net] 0.5 FROM_SUSPICIOUS_NTLD_FP From abused NTLD 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 2.5 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * guix/import/cabal.scm (is-id): Accept the location as an argument. =?UTF-8?Q?Don=E2=80=99t?= check if the identifier name is a reserved keyword unless it is the first word on the line. (lex-word): Adjust accordingly. [...] Content analysis details: (2.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager * guix/import/cabal.scm (is-id): Accept the location as an argument. Don= =E2=80=99t check if the identifier name is a reserved keyword unless it is the first w= ord on the line. (lex-word): Adjust accordingly. * tests/hackage ("hackage->guix-package tests flag executable"): Expect it = to pass. Fixes: --- =E2=80=98guix import hackage darcs=E2=80=99 now works correctly, and it fix= es 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: . * Distr= ibuted: 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 r= ecord one change in a file, while ignoring another. As you update from upst= ream, you can review each patch, picking and choosing which patches are app= ropriate. . * 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-ord= ered. 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 vi= ew of the state of a repository: it is given by the set of patches it conta= ins. Pulling and pushing patches merely transfers them from one set to anot= her. 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--- =20=20 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 =C2=A9 2015 Federico Beffa ;;; Copyright =C2=A9 2018 Ricardo Wurmus +;;; Copyright =C2=A9 2021 Xinglu Chen ;;; ;;; This file is part of GNU Guix. ;;; @@ -399,14 +400,20 @@ matching a string against the created regexp." =20 (define (is-or s) (string=3D? s "||")) =20 -(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 <>) por= t)) (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 reser= ved + ;; words, which would normally lead to an error, see + ;; . Unless th= e word + ;; is at the beginning of a line (excluding whitespace), treat is as j= ust + ;; another identifier instead of a reserved word. + (and (or (not (=3D (source-location-column loc) (current-indentation))) + (every (cut string-ci<> s <>) cabal-reserved-words))=20=20=20= =20=20=20=20=20=20 (and (not (char=3D? (last (string->list s)) #\:)) (not (char=3D? #\: c)))))) =20 @@ -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)))) =20 (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 >=3D 2.0 && < 3 ") =20 -;; Fails: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D25138 -(test-expect-fail 1) (test-assert "hackage->guix-package test flag executable" (eval-test-with-cabal test-cabal-flag-executable match-ghc-foo)) =20 base-commit: ec0e05ff306c950142c9ead7c712c749617069e7 --=20 2.33.0 From unknown Sat Jun 14 19:12:45 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Xinglu Chen Subject: bug#50588: closed (Re: [bug#50588] [PATCH] import: cabal: Treat identifier names correctly.) Message-ID: References: X-Gnu-PR-Message: they-closed 50588 X-Gnu-PR-Package: guix-patches X-Gnu-PR-Keywords: patch Reply-To: 50588@debbugs.gnu.org Date: Wed, 15 Sep 2021 12:33:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1631709182-2395-1" This is a multi-part message in MIME format... ------------=_1631709182-2395-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #50588: [PATCH] import: cabal: Treat identifier names correctly. which was filed against the guix-patches package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 50588@debbugs.gnu.org. --=20 50588: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D50588 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1631709182-2395-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 50588-done) by debbugs.gnu.org; 15 Sep 2021 12:32:18 +0000 Received: from localhost ([127.0.0.1]:51203 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mQU5K-0000bK-A7 for submit@debbugs.gnu.org; Wed, 15 Sep 2021 08:32:18 -0400 Received: from mout-p-102.mailbox.org ([80.241.56.152]:47336) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mQU5H-0000b4-4E for 50588-done@debbugs.gnu.org; Wed, 15 Sep 2021 08:32:17 -0400 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4H8fjh5wV9zQkBT; Wed, 15 Sep 2021 14:32:08 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6xq.net; s=MBO0001; t=1631709126; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=v5+n+eRc2RXUDF8Z01Ba4okIiJdYEVijXhbQIz7gttQ=; b=hFsA9VjNY7+2C9e89aS2hk4ExoOT3Q/DoN0atbFfYeXK7sNlmpI4BspMR/trXZrr7rhFKp X3VDB0dS2JBAj/YPjKw5nDqCL5AAK6i95BFo9Awl+iMW2aBX3o4zG/6vN1gqjRHHOh8h8L uSsS/hF0f16aFyXlnV0KNHzv/7GV6mHMy+3CXu2kKzYDA206acnv8faffB0AYvighdHfcN ArFeNeJ+XgNgtxidvASpsncKU8S//yBh1Qn1RsB9asOd9UTTK2eNpneaP4+0vqIrg7ivAa hqoiQDomPkrLp7zgy4uTtzv2tKb1MRJRJ/ZCtWkWJWlNmnnAMnVvM8Q6l74ogA== Date: Wed, 15 Sep 2021 14:32:03 +0200 From: Lars-Dominik Braun To: Xinglu Chen Subject: Re: [bug#50588] [PATCH] import: cabal: Treat identifier names correctly. Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 929CC183E X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 50588-done Cc: 50588-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Hi, looks good, pushed as a840caccaee8c9492f4cc8a7ba802ef54391f199 with some trailing whitespace removed. Cheers, Lars ------------=_1631709182-2395-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 14 Sep 2021 18:42:38 +0000 Received: from localhost ([127.0.0.1]:50170 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mQDO4-0007dV-He for submit@debbugs.gnu.org; Tue, 14 Sep 2021 14:42:38 -0400 Received: from lists.gnu.org ([209.51.188.17]:51626) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mQDO2-0007dN-Mp for submit@debbugs.gnu.org; Tue, 14 Sep 2021 14:42:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59874) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQDO1-0004Qe-CA for guix-patches@gnu.org; Tue, 14 Sep 2021 14:42:30 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:51212 helo=mail.yoctocell.xyz) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQDNz-000736-1Z for guix-patches@gnu.org; Tue, 14 Sep 2021 14:42:29 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1631644939; bh=BlowU9At9lSp4te1i30eWukhCDhQYk3Z0IS4wdlQJ8s=; h=From:To:Subject:Date; b=fFVcKKIw9g7PlzTN1WS1y12F7aeMJHy2QGnxMwfleXFEOeTDrdAlzU3KxRluqKyT9 lz7ZG4vt85zxmrk0iv0/JkO+fF2x7w8MvXao8Z3EbUUOPRfNxHBM6MjYMiI8LnxYpM ey2OCZaUJo/7U6DKo3zO0eadQLX69Qp8jYqNwhS4= To: guix-patches@gnu.org Subject: [PATCH] import: cabal: Treat identifier names correctly. Message-Id: Date: Tue, 14 Sep 2021 20:42:18 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=87.96.130.155; envelope-from=public@yoctocell.xyz; helo=mail.yoctocell.xyz X-Spam_score_int: 34 X-Spam_score: 3.4 X-Spam_bar: +++ X-Spam_report: (3.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.499, FROM_SUSPICIOUS_NTLD_FP=1.999, PDS_OTHER_BAD_TLD=1.999, RDNS_DYNAMIC=0.982, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.7 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * 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. [...] Content analysis details: (1.7 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [209.51.188.17 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.51.188.17 listed in wl.mailspike.net] 0.5 FROM_SUSPICIOUS_NTLD_FP From abused NTLD 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 2.5 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * 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. [...] Content analysis details: (2.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager * guix/import/cabal.scm (is-id): Accept the location as an argument. Don= =E2=80=99t check if the identifier name is a reserved keyword unless it is the first w= ord on the line. (lex-word): Adjust accordingly. * tests/hackage ("hackage->guix-package tests flag executable"): Expect it = to pass. Fixes: --- =E2=80=98guix import hackage darcs=E2=80=99 now works correctly, and it fix= es 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: . * Distr= ibuted: 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 r= ecord one change in a file, while ignoring another. As you update from upst= ream, you can review each patch, picking and choosing which patches are app= ropriate. . * 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-ord= ered. 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 vi= ew of the state of a repository: it is given by the set of patches it conta= ins. Pulling and pushing patches merely transfers them from one set to anot= her. 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--- =20=20 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 =C2=A9 2015 Federico Beffa ;;; Copyright =C2=A9 2018 Ricardo Wurmus +;;; Copyright =C2=A9 2021 Xinglu Chen ;;; ;;; This file is part of GNU Guix. ;;; @@ -399,14 +400,20 @@ matching a string against the created regexp." =20 (define (is-or s) (string=3D? s "||")) =20 -(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 <>) por= t)) (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 reser= ved + ;; words, which would normally lead to an error, see + ;; . Unless th= e word + ;; is at the beginning of a line (excluding whitespace), treat is as j= ust + ;; another identifier instead of a reserved word. + (and (or (not (=3D (source-location-column loc) (current-indentation))) + (every (cut string-ci<> s <>) cabal-reserved-words))=20=20=20= =20=20=20=20=20=20 (and (not (char=3D? (last (string->list s)) #\:)) (not (char=3D? #\: c)))))) =20 @@ -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)))) =20 (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 >=3D 2.0 && < 3 ") =20 -;; Fails: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D25138 -(test-expect-fail 1) (test-assert "hackage->guix-package test flag executable" (eval-test-with-cabal test-cabal-flag-executable match-ghc-foo)) =20 base-commit: ec0e05ff306c950142c9ead7c712c749617069e7 --=20 2.33.0 ------------=_1631709182-2395-1-- From unknown Sat Jun 14 19:12:45 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#50588] [PATCH] import: cabal: Treat identifier names correctly. Resent-From: zimoun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 15 Sep 2021 13:51:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50588 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Xinglu Chen Cc: 50588@debbugs.gnu.org Received: via spool by 50588-submit@debbugs.gnu.org id=B50588.163171380618267 (code B ref 50588); Wed, 15 Sep 2021 13:51:01 +0000 Received: (at 50588) by debbugs.gnu.org; 15 Sep 2021 13:50:06 +0000 Received: from localhost ([127.0.0.1]:51318 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mQVIZ-0004kX-Uq for submit@debbugs.gnu.org; Wed, 15 Sep 2021 09:50:06 -0400 Received: from mail-qk1-f170.google.com ([209.85.222.170]:38451) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mQVIJ-0004jd-K3 for 50588@debbugs.gnu.org; Wed, 15 Sep 2021 09:50:02 -0400 Received: by mail-qk1-f170.google.com with SMTP id f22so3450468qkm.5 for <50588@debbugs.gnu.org>; Wed, 15 Sep 2021 06:49:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=XWiUQxxJg4R65Sn2UHaFIP3ToSLCs1Ik0jo0cWNWsYE=; b=M669HPU7RIMOfDl9X0ce5AdVpp6TfsbuRuzwO7LEc8A7jRrGJQnBcq6QF732uoQ+eI 7pZSNJ5gES8lqcvPbHV0lnEYHW4Z4w6jmVYLcHFZaSF5lL7qp5yRzIiUnsQPOudFMRLK 4b0LMrle+C/OvsYV0ipLqt2dG10lE2mLfCxAVnzJWnZSVXJjsbS/jWtTFkeVTjvwHNZJ CcWGxT82BFxnsCiLv+B6zvidfk8i3WNSGjcz+UokpBp3n55qQ18Wmgxpm4bBnC6BX80v OOYGLVP6f0V8WRe18vjMrZ7N9+rz0DbmYb/HEjI+WMGFXEdYcoXFenVVqS7lflJxNfnw mngQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=XWiUQxxJg4R65Sn2UHaFIP3ToSLCs1Ik0jo0cWNWsYE=; b=PrnxM64Q2S7fQ//AasXSuVZ21Li/22/KnDDI9nF1MTAHZfbjFhsqI4KHp1/5q4MlAz /hvvocPwl6JXT9KFpiPIRZuaRY0u4BJUdY1/VqdfvW4V/DBPAZWSqex9SFQ+K5OdBPEE 9iSDsH/u28zh8VM+mJ2SN3BX+F/05ireT2uXC0ne2/YbMn/gls6IMgUrjqYsdG3hwdMx HG+ogWf5iWr7aa8FwuKRICYQkGr37J0BxE9yf7NqF8LbfE7SFOzTa4x+CVzSbYPXgu3x XhckVg5PLvitNt7xvWzDkbM8+qcwQGfe2dijApHkW3kU2HBGzOhY1ygXnYWXoZ62Qxj5 kcNg== X-Gm-Message-State: AOAM533CDa5LOw3GmJVF8L7oMpIU1SVDzk4WtdL4pEaXUtmD48mSrH+r X6xvI3i0ikImcYd5wMBEFy2VqeY7yE9sGLqhNZ9QPZvCUU0+4A== X-Google-Smtp-Source: ABdhPJydXl4fvs3dzjN59QdPirVa5BEgwCCAfalJSnZrtQ8vTthUr5ILOSbgKcxS43wZ/Kfap3HNobUC9NiNNDfCVQM= X-Received: by 2002:a05:620a:1035:: with SMTP id a21mr16453qkk.422.1631713781870; Wed, 15 Sep 2021 06:49:41 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: zimoun Date: Wed, 15 Sep 2021 09:55:57 +0200 Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 3.1 (+++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hi, On Tue, 14 Sept 2021 at 20:43, Xinglu Chen wrote: > * guix/import/cabal.scm (is-id): Accept the location as an argument. =?UTF-8?Q?Don=E2=80=99t?= > check if the identifier name is a reserved keyword unless it is the first word > on the line. > (lex-word): Adjust acco [...] Content analysis details: (3.1 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (zimon.toutoune[at]gmail.com) 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.1 DATE_IN_PAST_03_06 Date: is 3 to 6 hours before Received: date 0.0 T_SPF_TEMPERROR SPF: test of record failed (temperror) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 2.1 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hi, On Tue, 14 Sept 2021 at 20:43, Xinglu Chen wrote: > * guix/import/cabal.scm (is-id): Accept the location as an argument. =?UTF-8?Q?Don=E2=80=99t?= > check if the identifier name is a reserved keyword unless it is the first word > on the line. > (lex-word): Adjust acco [...] Content analysis details: (2.1 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (zimon.toutoune[at]gmail.com) 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.1 DATE_IN_PAST_03_06 Date: is 3 to 6 hours before Received: date -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.222.170 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.222.170 listed in list.dnswl.org] -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager Hi, On Tue, 14 Sept 2021 at 20:43, Xinglu Chen wrote: > * guix/import/cabal.scm (is-id): Accept the location as an argument. Don= =E2=80=99t > 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 i= t to > pass. > > Fixes: Oh awesome! Thanks! Yesterday, I was reviewing old bugs and dig the cabal parser was too intimidating. :-) Cheers, simon