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

Previous Next

Package: guile;

Reported by: Artyom Bologov <mail <at> aartaka.me>

Date: Thu, 24 Oct 2024 12:47:01 UTC

Severity: normal

To reply to this bug, email your comments to 73984 AT debbugs.gnu.org.

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

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


Report forwarded to bug-guile <at> gnu.org:
bug#73984; Package guile. (Thu, 24 Oct 2024 12:47:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Artyom Bologov <mail <at> aartaka.me>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Thu, 24 Oct 2024 12:47:02 GMT) Full text and rfc822 format available.

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

From: Artyom Bologov <mail <at> aartaka.me>
To: bug-guile <bug-guile <at> gnu.org>
Subject: Compiler/interpreter doesn't handle the macro defined after it's used
Date: Thu, 24 Oct 2024 16:45:11 +0400
[Message part 1 (text/plain, inline)]
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
;; ...
```

[test.scm (text/plain, attachment)]
[Message part 3 (text/plain, inline)]
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

Information forwarded to bug-guile <at> gnu.org:
bug#73984; Package guile. (Thu, 24 Oct 2024 14:52:02 GMT) Full text and rfc822 format available.

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

From: "Thompson, David" <dthompson2 <at> worcester.edu>
To: Artyom Bologov <mail <at> aartaka.me>
Cc: 73984 <at> debbugs.gnu.org
Subject: Re: bug#73984: Compiler/interpreter doesn't handle the macro defined
 after it's used
Date: Thu, 24 Oct 2024 10:49:36 -0400
Hi Artyom,

On Thu, Oct 24, 2024 at 8:47 AM Artyom Bologov <mail <at> aartaka.me> wrote:
>
> 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 <at> gnu.org:
bug#73984; Package guile. (Thu, 24 Oct 2024 15:14:01 GMT) Full text and rfc822 format available.

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

From: Artyom Bologov <mail <at> aartaka.me>
To: "Thompson, David" <dthompson2 <at> worcester.edu>
Cc: 73984 <at> debbugs.gnu.org
Subject: Re: bug#73984: Compiler/interpreter doesn't handle the macro
 defined after it's used
Date: Thu, 24 Oct 2024 19:13:10 +0400
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




This bug report was last modified 289 days ago.

Previous Next


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