unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* [critical bug] The set! doesn't work in indirect reference
@ 2024-09-18 14:37 Nala Ginrut
  2024-09-18 14:50 ` Thompson, David
  0 siblings, 1 reply; 3+ messages in thread
From: Nala Ginrut @ 2024-09-18 14:37 UTC (permalink / raw)
  To: bug-guile; +Cc: Guile User

Hi folks!
Recently I was bothered by a strange bug when debugging Artanis, here's how
to reproduce.
You need three files, say aaa.scm, bbb.scm, and entry

---------------------aaa.scm----------------
(define-module (aaa)
 #:export (global))

(define global #f)
----------------------aaa.scm end------------

------------------bbb.scm----------------
(define-module (bbb)
 #:use-module (aaa)
 #:export (fun))

(define (fun)
 (pk 'before global)
 (set! global 123)
 (pk 'after global))
-------------------bbb.scm end-------------



------------------entry-------------
(import (bbb))

(fun)
-----------------entry end-------------


Put all files in the same directory, and run:
----------------cut----------------
guile -L . entry
----------------end---------------


The result is:
;;; (before #f)
;;; (after #f)

The expected result should be:
;; (before #f)
;; (after 123)

------------------------------------------

This was tested in 3.0.9 and 3.0.10.

I also CC  guile-user list, in case anyone was troubled by strange bugs,
this may be a hint.


Best regards.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [critical bug] The set! doesn't work in indirect reference
  2024-09-18 14:37 [critical bug] The set! doesn't work in indirect reference Nala Ginrut
@ 2024-09-18 14:50 ` Thompson, David
  2024-09-19  2:34   ` Nala Ginrut
  0 siblings, 1 reply; 3+ messages in thread
From: Thompson, David @ 2024-09-18 14:50 UTC (permalink / raw)
  To: Nala Ginrut; +Cc: bug-guile, Guile User

On Wed, Sep 18, 2024 at 10:38 AM Nala Ginrut <nalaginrut@gmail.com> wrote:
>
> The result is:
> ;;; (before #f)
> ;;; (after #f)
>
> The expected result should be:
> ;; (before #f)
> ;; (after 123)

I don't think this is a bug. Both modules are declarative (the
default). 'global' from module (aaa) is presumably being inlined into
the 'pk' calls in module (bbb).  If you mark module (bbb) as
'#:declarative? #f' then you get your expected result.

Hope this helps,

- Dave



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [critical bug] The set! doesn't work in indirect reference
  2024-09-18 14:50 ` Thompson, David
@ 2024-09-19  2:34   ` Nala Ginrut
  0 siblings, 0 replies; 3+ messages in thread
From: Nala Ginrut @ 2024-09-19  2:34 UTC (permalink / raw)
  To: Thompson, David; +Cc: bug-guile, Guile User

Thanks for the reply!
I've taken a look at
https://www.gnu.org/software/guile/manual/html_node/Declarative-Modules.html
It's related to #:declarative?

Thanks again!
Best regards.


On Wed, Sep 18, 2024 at 11:50 PM Thompson, David <dthompson2@worcester.edu>
wrote:

> On Wed, Sep 18, 2024 at 10:38 AM Nala Ginrut <nalaginrut@gmail.com> wrote:
> >
> > The result is:
> > ;;; (before #f)
> > ;;; (after #f)
> >
> > The expected result should be:
> > ;; (before #f)
> > ;; (after 123)
>
> I don't think this is a bug. Both modules are declarative (the
> default). 'global' from module (aaa) is presumably being inlined into
> the 'pk' calls in module (bbb).  If you mark module (bbb) as
> '#:declarative? #f' then you get your expected result.
>
> Hope this helps,
>
> - Dave
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-09-19  2:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-18 14:37 [critical bug] The set! doesn't work in indirect reference Nala Ginrut
2024-09-18 14:50 ` Thompson, David
2024-09-19  2:34   ` Nala Ginrut

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).