From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id sGP5M8z7w2F5VwEAgWs5BA (envelope-from ) for ; Thu, 23 Dec 2021 05:32:12 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id IBS6L8z7w2EpaQAA1q6Kng (envelope-from ) for ; Thu, 23 Dec 2021 04:32:12 +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 82F162DF7F for ; Thu, 23 Dec 2021 05:32:12 +0100 (CET) Received: from localhost ([::1]:34666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n0Flz-0005Bs-J9 for larch@yhetil.org; Wed, 22 Dec 2021 23:32:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0Flr-0005BW-Dj for bug-guix@gnu.org; Wed, 22 Dec 2021 23:32:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:48628) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n0Flr-0005Nk-44 for bug-guix@gnu.org; Wed, 22 Dec 2021 23:32:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n0Flq-00014L-JV for bug-guix@gnu.org; Wed, 22 Dec 2021 23:32:02 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#52749: G-expressions don't consistently preserve #nil Resent-From: Philip McGrath Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Thu, 23 Dec 2021 04:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 52749 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 52749@debbugs.gnu.org X-Debbugs-Original-To: bug-guix@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16402338914068 (code B ref -1); Thu, 23 Dec 2021 04:32:02 +0000 Received: (at submit) by debbugs.gnu.org; 23 Dec 2021 04:31:31 +0000 Received: from localhost ([127.0.0.1]:60174 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n0FlL-00013Y-EG for submit@debbugs.gnu.org; Wed, 22 Dec 2021 23:31:31 -0500 Received: from lists.gnu.org ([209.51.188.17]:36324) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n0FlJ-00013R-Un for submit@debbugs.gnu.org; Wed, 22 Dec 2021 23:31:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59152) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0FlJ-00059s-Lt for bug-guix@gnu.org; Wed, 22 Dec 2021 23:31:29 -0500 Received: from [2607:f8b0:4864:20::f2f] (port=42538 helo=mail-qv1-xf2f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n0FlH-0005Fd-Ul for bug-guix@gnu.org; Wed, 22 Dec 2021 23:31:29 -0500 Received: by mail-qv1-xf2f.google.com with SMTP id q4so4149977qvh.9 for ; Wed, 22 Dec 2021 20:31:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philipmcgrath.com; s=google; h=message-id:date:mime-version:user-agent:content-language:to:from :subject:content-transfer-encoding; bh=9OMq/pqjbd6YPw2p3JoLOo0pP/EXfOC/dJ9XXSgEK3M=; b=O0hu82qLVgL2C8585GAJxyCg07bqTBI/qQljT/UavR4sxSi35xFH0Qb5AADNDPWK6F 44c2hxmrpLxhYQ3z91f25Qgaao0+VvJaV59Z6OtPO8uSuGoQ/2DZDjEN6yml8gd5QC36 uqIBPzfyq297+xgAiTbS/v5M42yLgUjxx93gGH0UduxcXAe8dXRpRACB/SedOWbnXGDe QwPBbrvA2C9JIcT0CnvH9VloQ/juFbwr/PVgIQuAdlWKwBEx4Trni23D+BYcjA7l9Xn2 ywBtQT0b2Un4OsUG/obSHdNW/blh8fqFs1TSqulPq5usmwpLiHeqI6bbNoZ7maJsn/sJ eqbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:from:subject:content-transfer-encoding; bh=9OMq/pqjbd6YPw2p3JoLOo0pP/EXfOC/dJ9XXSgEK3M=; b=og/kV7/QhJFloBCGFc3D6LvmNuiTFTfMRE3MyHVWztFJOCINWW9/A3oWSnDbYTYLee GDCESqXE8Uo3kRDrrVAwylTyyOUIYsblT+k2R+8/8mA1Gx0csvVpHbzgkgMu/63wqUKV ZksM5I7wU7Lb09E+ZsmB0I9YG01Gcn9vyW1mybO3Ob8a94TTJyMtgOSv/vnkWefQ8KQf YdlGZ2fGalFfjmUHC09p2pwjSNyCvZ0zKWTO2zGrtX9+2AabrJ71lDNjWbDjdIx6JT2m kuhb7+xezdYLUz+61rwsu+okhI7VFYbGEdYkw7ApHEBdGHNBQdiY0dr2eSImM2bgIL3o LvaQ== X-Gm-Message-State: AOAM531XPEWhiItLCUDJugh0smTMT21xYP3sSxhS0MYC6XCNeS9GsnPu r4hedRRetl7+xFz9sjPt0snBXTdOvMzMGoHc X-Google-Smtp-Source: ABdhPJwnPPn8cwSyrBMZ2sGomuoOplKVVhOxAOCUdTOrWeOlT86mvDwCnJdR6tGL6mbT4wKD/QXdZA== X-Received: by 2002:a05:6122:a29:: with SMTP id 41mr206982vkn.25.1640233536186; Wed, 22 Dec 2021 20:25:36 -0800 (PST) Received: from [192.168.45.37] (c-73-125-89-242.hsd1.fl.comcast.net. [73.125.89.242]) by smtp.gmail.com with ESMTPSA id i123sm781710vkb.20.2021.12.22.20.25.35 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Dec 2021 20:25:36 -0800 (PST) Message-ID: <23d2ac1d-737d-787c-5535-c816566461dd@philipmcgrath.com> Date: Wed, 22 Dec 2021 23:25:35 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.1 Content-Language: en-US From: Philip McGrath Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::f2f (failed) Received-SPF: neutral client-ip=2607:f8b0:4864:20::f2f; envelope-from=philip@philipmcgrath.com; helo=mail-qv1-xf2f.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NEUTRAL=0.779 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: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1640233932; 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=9OMq/pqjbd6YPw2p3JoLOo0pP/EXfOC/dJ9XXSgEK3M=; b=rqp4pjwkC9VzqiVqfpVKoCgWfBy6La/KiAtAkgXzi0SLqZnbLVw5WqjqvFv4VmJprVU9Od PmJivz5w++5smqS9isjJ3sjwF9R5sOpZnHt4MipaOxxfLmaTN6McH9Xj7zvgdRfUEF8Ghk Hsuo5QgvQB5omYaMU++Db4uu6WlCrFB27eNRWfAKbaC/AdxBe8UBxlgsdFR0BbY7ylc6Sb qNvZuO9EnxdrG7QAIRTpueEwjKv8l57cGkGQ4kYFZx0jW0Nh9Qz+OeIpHoJCaHYP1YiwP9 3Opgo5mxrtBJGTazUxlU/1FDRGRre5y5O+yRHmGXjp9q/u/7GSKGO7n1HDKMMg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1640233932; a=rsa-sha256; cv=none; b=lB+248pCruasMLUNcCvp9mwmeDUXL218PLgGnzRsAa6GXEt08AfFG0uuXaMEUI7T3Ukzx/ RlYDs8yjgtf9hr775wRYXKnK1lIZWXGxonky6QTlnyzoTqkPlSd450D1aL5X3ZBJQtAmR1 Xlj7eq4MXaJMBZjpZgZETLya8PQbrqFqIcoBywdq70GYWCUVRJ7AvS4RucTJX7Dl19C8Zu rn0uh/EorQRm+4R5zgsN+AMB5v0HjcJEZ1QZplZkPnnAgcKTKOdDp+JwKIRqQw3VjKn8R6 zBrmQNjhpNCY2KlAX1tmYJU6DcRY7Mn9K+YlFXI2iZCNgaesDJW4mZSd2+AgKA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=O0hu82qL; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.74 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=O0hu82qL; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 82F162DF7F X-Spam-Score: -3.74 X-Migadu-Scanner: scn0.migadu.com X-TUID: NvmnXIcGJ2Bf G-expressions currently do not consistently preserve the distinction between #nil and '(), which causes trouble for programs that rely on that distinction. In particular, the issue affects programs that use (guix build json), because that library uses #nil to represent the JSON value `null', whereas it uses '() to represent an empty JSON array. The following program exposes the error: --8<---------------cut here---------------start------------->8--- (use-modules (guix build json) (guix gexp) (guix monads) (guix store) (guix derivations) (rnrs conditions) (ice-9 textual-ports)) (define (check-equal? actual expected message) (define who 'check-equal?) (unless (equal? actual expected) (raise-exception (condition (make-assertion-violation) (make-who-condition 'check-equal?) (make-irritants-condition (list actual)) (make-message-condition (format #f "~a: ~a\n ~a: ~s\n ~a: ~s\n ~a: ~s" who "test failed" "message" message "expected" expected "actual" actual)))))) (define (sexp->json-string sx) (call-with-output-string (lambda (out) (write-json sx out)))) (define (gexp->json-string gx) (run-with-store (open-connection) (mlet* %store-monad ((drv (gexp->derivation "example.json" (with-imported-modules `((guix build json)) #~(begin (use-modules (guix build json)) (call-with-output-file #$output (lambda (out) (write-json #$gx out))))))) (_built (built-derivations (list drv)))) (return (call-with-input-file (derivation->output-path drv) get-string-all))))) (check-equal? (sexp->json-string '()) "[]" "sexp: empty array") (check-equal? (gexp->json-string #~'()) "[]" "gexp: empty array") (check-equal? (sexp->json-string #nil) "null" "sexp: null") (check-equal? (gexp->json-string #~#nil) "null" "gexp: null") (check-equal? (sexp->json-string '(@ ("k" . #nil))) "{\"k\":null}" "sexp: null in object") ;; This one fails! (check-equal? (gexp->json-string #~'(@ ("k" . #nil))) "{\"k\":null}" "gexp: null in object") --8<---------------cut here---------------end--------------->8--- -Philip