GNU bug report logs - #73984
Compiler/interpreter doesn't handle the macro defined after it's used

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guile; Reported by: Artyom Bologov <mail@HIDDEN>; dated Thu, 24 Oct 2024 12:47:01 UTC; Maintainer for guile is bug-guile@HIDDEN.

Message received at 73984 <at> debbugs.gnu.org:


Received: (at 73984) by debbugs.gnu.org; 24 Oct 2024 15:13:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 24 11:13:56 2024
Received: from localhost ([127.0.0.1]:35894 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1t3zXA-0000dJ-Kv
	for submit <at> debbugs.gnu.org; Thu, 24 Oct 2024 11:13:56 -0400
Received: from layka.disroot.org ([178.21.23.139]:33844)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1t3zX8-0000d1-JC
 for 73984 <at> debbugs.gnu.org; Thu, 24 Oct 2024 11:13:55 -0400
Received: from mail01.disroot.lan (localhost [127.0.0.1])
 by disroot.org (Postfix) with ESMTP id 84FF3252CD;
 Thu, 24 Oct 2024 17:13:22 +0200 (CEST)
X-Virus-Scanned: SPAM Filter at disroot.org
Received: from layka.disroot.org ([127.0.0.1])
 by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP
 id Qrcox9qTD7jZ; Thu, 24 Oct 2024 17:13:21 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aartaka.me; s=mail;
 t=1729782801; bh=rxvMlZPg3C+pmq3o8a9HorA/I3ReR9dZGi5azHo3MPQ=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date;
 b=1H/bfE6ojOQj1FhjrzRLIamMHFWSdRZwLr4VOYE/j1o8FLyp2by6Iwk7nroeAI61q
 9sv9e1z4y3thjzaVcwk7uR6eIYE8HV1yJAkx3H1Wpoi84PbWeONiebvHk84OudMu1T
 urt/dhIdRtyPyr3XLXbZfC+WpKVxuXt9C872XpvYV8w4Rg7BEC4gIzyrAqsi8fAOE4
 fpau4ya5JVcrjttfoYMsMn1sOpdMxiTlmk4pY1czOehnIIv/SKqWAFWooHv/m8kHts
 YiMBJISlLTg1RmQUfJWv+12f1VLhjV+M7BCSd2xPJKjUlHl7Am8iR+/c+8A/O3rj7g
 dLnBjeKRcWZpg==
From: Artyom Bologov <mail@HIDDEN>
To: "Thompson, David" <dthompson2@HIDDEN>
Subject: Re: bug#73984: Compiler/interpreter doesn't handle the macro
 defined after it's used
In-Reply-To: <CAJ=Rwfa9mFjzrG-NdJogw6EQdu2XdWvNKWL4MPXDzdjc7WLkdg@HIDDEN>
 (David Thompson's message of "Thu, 24 Oct 2024 10:49:36 -0400")
References: <87bjz9mzzc.fsf@HIDDEN>
 <CAJ=Rwfa9mFjzrG-NdJogw6EQdu2XdWvNKWL4MPXDzdjc7WLkdg@HIDDEN>
Date: Thu, 24 Oct 2024 19:13:10 +0400
Message-ID: <8734klilfd.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 73984
Cc: 73984 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi David,

> I don't think this is a bug. In my experience, macro definitions must
> precede uses.

This is a sane answer too!

Thanks,
-- 
Artyom Bologov
https://aartaka.me




Information forwarded to bug-guile@HIDDEN:
bug#73984; Package guile. Full text available.

Message received at 73984 <at> debbugs.gnu.org:


Received: (at 73984) by debbugs.gnu.org; 24 Oct 2024 14:51:28 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 24 10:51:28 2024
Received: from localhost ([127.0.0.1]:35875 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1t3zBQ-00081M-4A
	for submit <at> debbugs.gnu.org; Thu, 24 Oct 2024 10:51:28 -0400
Received: from mail-qt1-f173.google.com ([209.85.160.173]:50415)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dthompson2@HIDDEN>) id 1t3zBL-00080y-TI
 for 73984 <at> debbugs.gnu.org; Thu, 24 Oct 2024 10:51:26 -0400
Received: by mail-qt1-f173.google.com with SMTP id
 d75a77b69052e-46094b68e30so6157071cf.0
 for <73984 <at> debbugs.gnu.org>; Thu, 24 Oct 2024 07:50:53 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=worcester.edu; s=google; t=1729781387; x=1730386187; darn=debbugs.gnu.org;
 h=content-transfer-encoding:cc:to:subject:message-id:date:from
 :in-reply-to:references:mime-version:from:to:cc:subject:date
 :message-id:reply-to;
 bh=yD9shtIS6Qa2Ksxd6tFxCZmzGUutjij0Je8DAgNMGno=;
 b=WGlyce1KmlpsvjANDFkKlPjRGr8MrEisbTpc8S8Tpe5UO/A9v/S85x8IAqYs4Oeyk6
 sYZ+PIzyJ2lHcjkUYcFwX1ikYbXtHjZ4PZLL1yq7xqPmwx5kovKeqQNWjCTaadKf3hXt
 BG3HuM9/1Fccbr7slHFY+aixPpINEeWIyN6vs=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1729781387; x=1730386187;
 h=content-transfer-encoding:cc:to:subject:message-id:date:from
 :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=yD9shtIS6Qa2Ksxd6tFxCZmzGUutjij0Je8DAgNMGno=;
 b=wWzDnltbjx7endEw+O/yJI/8+2kinA8Jw9J5GKbDqrgEGq/XudzIkCq8gWK5M0ApBo
 2QGsQghK7pwgD6ap+YUrUEQOuwpewWurjOwqCbdHROnVKP+gQzLxwtmdHrC6Yrd82mg6
 A2s6WSLWChM6rt1Km6vdZ0ww4L9ORsYwxXS/tLCdB5lU2kUqeTdDTF+lxNV3+/HbIKsS
 pVnQZek84Vhh3b5cBcb+lSxkh3BzqrYaKCOryvoQgdxHfpEf53HWK7R+1zMj6CmUzAUl
 PdFMjcxNFSh4tPuNRxm05O2m90O9sv5hM045jn3vnT5sqtRjyuofBzw0kXNoBXVAatiV
 2UKg==
X-Gm-Message-State: AOJu0YzCpzZeQpO8iebT/yGxtC+gSBGBPoofzS2pbEL8/qb7rtdALi7y
 Zhfz4eAzcgIw8KfTNTVLCAx8G8XJ4SnwUQqecCB6XRxJTVLwpR1HwIwynOgoPu+/qXdfHljn7lZ
 xbhLk3L8YVS1ofOPzMdEzFaYNaKWMkzxTcVX0pA==
X-Google-Smtp-Source: AGHT+IEH/u+0ALkUdaDzQhda5aDRaX3I9ksYpWoufVSNOMYxDq30TOLdzuXxjxIFfX86yNn3+YKCvWgR09Qmw/8Rsjw=
X-Received: by 2002:ac8:5f8e:0:b0:461:2616:8490 with SMTP id
 d75a77b69052e-4612616859cmr17814391cf.29.1729781387575; Thu, 24 Oct 2024
 07:49:47 -0700 (PDT)
MIME-Version: 1.0
References: <87bjz9mzzc.fsf@HIDDEN>
In-Reply-To: <87bjz9mzzc.fsf@HIDDEN>
From: "Thompson, David" <dthompson2@HIDDEN>
Date: Thu, 24 Oct 2024 10:49:36 -0400
Message-ID: <CAJ=Rwfa9mFjzrG-NdJogw6EQdu2XdWvNKWL4MPXDzdjc7WLkdg@HIDDEN>
Subject: Re: bug#73984: Compiler/interpreter doesn't handle the macro defined
 after it's used
To: Artyom Bologov <mail@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 73984
Cc: 73984 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi Artyom,

On Thu, Oct 24, 2024 at 8:47=E2=80=AFAM Artyom Bologov <mail@HIDDEN> wr=
ote:
>
> Hello y'all,
>
> So I'm working on a project with a moderate amount of macros and some
> tangled code paths. Which often means I have non-linear and
> hard-to-figure-out inter-dependencies between pieces of code. One of
> them bit me today: a macro that was defined after a procedure it was
> used in, resulted in an "Unbound variable" error when the procedure was
> called. The procedure was called long after the macro was finally
> defined, so it shouldn't have been a problem.

I don't think this is a bug. In my experience, macro definitions must
precede uses.

- Dave




Information forwarded to bug-guile@HIDDEN:
bug#73984; Package guile. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 24 Oct 2024 12:46:04 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 24 08:46:04 2024
Received: from localhost ([127.0.0.1]:34009 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1t3xE4-0001TI-A6
	for submit <at> debbugs.gnu.org; Thu, 24 Oct 2024 08:46:04 -0400
Received: from lists.gnu.org ([209.51.188.17]:53672)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1t3xE1-0001Ss-Lf
 for submit <at> debbugs.gnu.org; Thu, 24 Oct 2024 08:46:02 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <mail@HIDDEN>) id 1t3xDW-0003Fc-O1
 for bug-guile@HIDDEN; Thu, 24 Oct 2024 08:45:30 -0400
Received: from layka.disroot.org ([178.21.23.139])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <mail@HIDDEN>) id 1t3xDU-0001fe-Qt
 for bug-guile@HIDDEN; Thu, 24 Oct 2024 08:45:30 -0400
Received: from mail01.disroot.lan (localhost [127.0.0.1])
 by disroot.org (Postfix) with ESMTP id E6F6225136;
 Thu, 24 Oct 2024 14:45:14 +0200 (CEST)
X-Virus-Scanned: SPAM Filter at disroot.org
Received: from layka.disroot.org ([127.0.0.1])
 by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP
 id jo-XMOip6yH7; Thu, 24 Oct 2024 14:45:14 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aartaka.me; s=mail;
 t=1729773914; bh=rjbZqIutqyU+1HFgoejabLKQbIsDJ2/usDRkYbrHcME=;
 h=From:To:Subject:Date;
 b=lXDwxWeCmpHZ17XmU7ltMzCFvlAR26hZpPpECMex5pfIv12wtEsY2rn5Hyb/isBDw
 Zfl5aibX2aD2VNGEupU2p6mEK6UrHV5sTZLiZicMQ6n0tEn74xcJQNzBzhq/zS+x8l
 3rtyvqUdEp0eKTiZdKL/xCAN+4+zysFmSqucer3g913TtHY9AYaN75L3+12S3Hxxyj
 p0DoDjSJ/UkR/hNY2LIpKnMPQjBhhvjZerC6I2Nj8ZqTe7raNkKOlIyaNJ9LvoCn01
 Gq2cZQse6O6/Be5z66XBvV6SHy6/O8GKpY6l7ipVkSxFko6VRfk2+xhsVpucsP75Sw
 QdxJtAaIN6oUg==
From: Artyom Bologov <mail@HIDDEN>
To: bug-guile <bug-guile@HIDDEN>
Subject: Compiler/interpreter doesn't handle the macro defined after it's used
Date: Thu, 24 Oct 2024 16:45:11 +0400
Message-ID: <87bjz9mzzc.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: none client-ip=178.21.23.139; envelope-from=mail@HIDDEN;
 helo=layka.disroot.org
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 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_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001,
 SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

--=-=-=
Content-Type: text/plain

Hello y'all,

So I'm working on a project with a moderate amount of macros and some
tangled code paths. Which often means I have non-linear and
hard-to-figure-out inter-dependencies between pieces of code. One of
them bit me today: a macro that was defined after a procedure it was
used in, resulted in an "Unbound variable" error when the procedure was
called. The procedure was called long after the macro was finally
defined, so it shouldn't have been a problem. Find the test file
attached and use it as:

```
GUILE_LOAD_PATH=.:$GUILE_LOAD_PATH guile
scheme@(guile-user)> (use-modules (test))
;;; note: source file ./test.scm
;;;       newer than compiled /.../test.scm.go
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling ./test.scm
;;; test.scm:7:5: warning: possibly unbound variable `a'
;;; test.scm:8:5: warning: possibly unbound variable `b'
;;; compiled /.../test.scm.go
scheme@(guile-user)> (testing)
;; ice-9/boot-9.scm:1685:16: In procedure raise-exception:
;; Unbound variable: a
;; ...
```


--=-=-=
Content-Type: text/plain
Content-Disposition: attachment; filename=test.scm
Content-Description: Scheme file to test forward definition problem

(define-module (test)
  #:export-syntax (with-something)
  #:export (testing))

(define (testing)
  (with-something
   ((a 1)
    (b a))
   'hello))

(define-syntax-rule (with-something ((var init) ...) body ...)
  (let* ((var init) ...)
    (begin body ...)
    #t))

--=-=-=
Content-Type: text/plain


The expected behavior is that both "a" and "b" are defined and macro
expanded during compilation, regardless of whether it was defined before
or after use.

I'm not sure if that's a valid bug, but here you go anyway.

Best of love,
-- 
Artyom Bologov
https://aartaka.me

--=-=-=--




Acknowledgement sent to Artyom Bologov <mail@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-guile@HIDDEN. Full text available.
Report forwarded to bug-guile@HIDDEN:
bug#73984; Package guile. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sun, 12 Jan 2025 05:45:02 UTC

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