guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Guile import issue


From: Zelphir Kaltstahl
Subject: Guile import issue
Date: Wed, 14 Jun 2023 20:15:46 +0000

Hello Guile Users!

I have now created a minimal example of the import bug or issue I am observing:

~~~~rectangular.scm~~~~
(library (rectangular)
  (export real-part)

  (import (except (rnrs base) error)
          (only (guile)
                lambda* λ))

  (define real-part
    (λ (num)
      (car num))))
~~~~

~~~~solution.scm~~~~
(import (except (rnrs base) error)
        (only (guile)
              lambda* λ)
        (prefix (rectangular) rect:))


(define real-part
  (λ (datum)
    (rect:real-part datum)))


(real-part '(1 . 2))
~~~~

~~~~shell~~~~
$ guile --version
guile (GNU Guile) 3.0.9
Copyright (C) 2023 Free Software Foundation, Inc.

License LGPLv3+: GNU LGPL 3 or later<http://gnu.org/licenses/lgpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

$ guile -L . solution.scm
Backtrace:
In ice-9/boot-9.scm:
  1752:10  6 (with-exception-handler _ _ #:unwind? _ # _)
In unknown file:
           5 (apply-smob/0 #<thunk 7fc30540b300>)
In ice-9/boot-9.scm:
    724:2  4 (call-with-prompt ("prompt") #<procedure 7fc30541bf80 …> …)
In ice-9/eval.scm:
    619:8  3 (_ #(#(#<directory (guile-user) 7fc30540ec80>)))
In ice-9/boot-9.scm:
   2836:4  2 (save-module-excursion #<procedure 7fc3053ff210 at ice-…>)
  4388:12  1 (_)
In unknown file:
           0 (real-part (1 . 2))

ERROR: In procedure real-part:
In procedure real-part: Wrong type argument in position 1: (1 . 2)
~~~~

As you can see, Guile complains about getting a pair as argument for `real-part'. This is, because it still tries to use the original `real-part', rather than the one I imported. I am calling `real-part' by using `rect:real-part', so it should be even clearer, which `real-part' function it is supposed to use.

This feels like a bug to me. Am I overlooking something very simple, or misunderstanding something fundamental about modules or imports? I am really surprised, that I have not hit this earlier in my Guile usage. Is this perhaps only in 3.0.9?

Best regards,
Zelphir

--
repositories:https://notabug.org/ZelphirKaltstahl


reply via email to

[Prev in Thread] Current Thread [Next in Thread]