From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id yFfkFD/tQGGeTAAAgWs5BA (envelope-from ) for ; Tue, 14 Sep 2021 20:43:11 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id cCSDED/tQGEQCAAA1q6Kng (envelope-from ) for ; Tue, 14 Sep 2021 18:43:11 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 550191E41A for ; Tue, 14 Sep 2021 20:43:10 +0200 (CEST) Received: from localhost ([::1]:48268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQDOf-0004Un-G0 for larch@yhetil.org; Tue, 14 Sep 2021 14:43:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQDOY-0004Uf-V0 for guix-patches@gnu.org; Tue, 14 Sep 2021 14:43:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38624) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mQDOY-0007ak-NH for guix-patches@gnu.org; Tue, 14 Sep 2021 14:43:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mQDOY-0007eJ-Jh for guix-patches@gnu.org; Tue, 14 Sep 2021 14:43:02 -0400 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1631644990; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=02BVkSv7+PGySATeKrH7pJCK+ZxUoE+EY61885p5lQc=; b=r/fiPBcK/j9srAkw35Jl4xdDCyyd1Sk1kuMl1JT2fsLxnkYAK9V1qp0Eguf9KqM5JWa9NC RGPGV9OdmttIO2EXjm3DpnrPz9GgKXCmU9lE3YPaET7KL4uRIsjWKeCJUFphcCdMBxUFwn Qs56/BoEfTnEGtwWlXFlC5hUKiy0BnoEcOGMpuidS2UMZb55kSMVgokc97xUBjQJZsqpJ4 oInKkAejPVARIZ+JHQ88gu8sctso/vDthH8gpHKKn1EfL60BN/4p3vgbz/wKfsa9w93+fC TzQybykpJW/W6UsGmrQ8oCGPHLMv8oEXv1PW8oLAYO01UMp+QXVzytsGeq6BUA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1631644990; a=rsa-sha256; cv=none; b=m1WKEy6XuaYIRaHKv7Ej2mBpQ7wyIwN5hdUp/S0ca6qw37IlMwKg7NXahL9EBoEUUgZxO3 j1l14BzRjFhR/Z7LCB1W2gqN7JxkKoBHq2cap1uoapmYF8rrZj4eLDrvpOnJ7oKTXFPm3A feJnTEw0AMR51lsLV/kqXDnOWdf8iTt5/0ZHZj9rFYRP1WIT6H9LIBtGB5zvOdiKP+uvWh PGDKm7mY5QidtpGJwwFN70Dp0LJcoQPxZkjv00vet+DQ7O7T3O8BiGLTpN9J1ZdLpDufqx gQJatyKLYSh0evxy12BLOYVmb7eBlauqC4b2BHslcX76s+ZVP5/MhOGHPmHpzg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=yoctocell.xyz header.s=mail header.b=fFVcKKIw; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -0.30 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=yoctocell.xyz header.s=mail header.b=fFVcKKIw; dmarc=fail reason="SPF not aligned (relaxed)" header.from=yoctocell.xyz (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 550191E41A X-Spam-Score: -0.30 X-Migadu-Scanner: scn0.migadu.com X-TUID: pnW2Jc/qSseK * 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