Guile Macros did not print the error-line-number ?

  • Open
  • quality assurance status badge
Details
2 participants
  • Joshua Branson
  • Ludovic Courtès
Owner
unassigned
Submitted by
Joshua Branson
Severity
normal
J
J
Joshua Branson wrote on 1 Feb 2021 19:12
(address . bug-guix@gnu.org)(address . bug-guile@gnu.org)
87r1lzodwl.fsf@dismail.de
Hello!

Recently on irc, I posted an example of an incorrectly used
define-record-type* NOT displaying an error line number.

mdevos mentioned that this could potentially be fixed in (guix
records), but it may also be a guile compile bug as well.

First here is a (guix records) example:

#+BEGIN_SRC scheme
(use-modules (guix records))

(define-record-type* <sway-bindsym>
sway-bindsym make-sway-bindsym
sway-bindsym?
(key-combo sway-bindsym-key-combo
(default "")))

(display sway-bindsym) ;; compile error at unknown location
;; (display (sway-bindsym)) this is one "correct" way to call this code
#+END_SRC

One will get a compile error like the following

#+BEING_SRC sh
;;; note: source file /home/joshua/prog/guile/test.scm
;;; newer than compiled /home/joshua/.cache/guile/ccache/3.0-LE-8-4.4/home/joshua/prog/guile/test.scm.go
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;; or pass the --no-auto-compile argument to disable.
;;; compiling /home/joshua/prog/guile/test.scm
;;; WARNING: compilation of /home/joshua/prog/guile/test.scm failed:
;;; Syntax error:
;;; unknown location: source expression failed to match any pattern in form sway-bindsym
ice-9/psyntax.scm:2800:12: In procedure syntax-violation:
Syntax error:
unknown location: source expression failed to match any pattern in form sway-bindsym
#+END_SRC

As you can see, you do NOT see a error-line-number. If this file was
sufficiently large, this might be hard to track down. Though it IS
NICE to see that the error comes from an "sway-bindsym".

mdevos then mentioned that I should provide a simple use case NOT
involving (guix records). Here is one:

#+BEGIN_SRC scheme
(define-syntax when
(syntax-rules ()
((when condititon exp ...)
(if condititon
(begin exp ...)))))

(when #t (display "Hello\n"))

(display when)
#+END_SRC

The error message looks like:

#+BEGIN_SRC sh
;;; note: source file /home/joshua/prog/guile/macro-bug.scm
;;; newer than compiled /home/joshua/.cache/guile/ccache/3.0-LE-8-4.4/home/joshua/prog/guile/macro-bug.scm.go
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;; or pass the --no-auto-compile argument to disable.
;;; compiling /home/joshua/prog/guile/macro-bug.scm
;;; WARNING: compilation of /home/joshua/prog/guile/macro-bug.scm failed:
;;; Syntax error:
;;; unknown location: source expression failed to match any pattern in form when
Hello
ice-9/psyntax.scm:2800:12: In procedure syntax-violation:
Syntax error:
unknown location: source expression failed to match any pattern in form when
#+END_SRC

Again, I do not see an error-line-number message.

Thanks,

Joshua

P.S. I am no scheme compiler expert. As far as I know, maybe it's
impossible to display the error-line-number, when you use macros. I
just heard that few free software users report bugs. I'm just trying
to be helpful. :) I hope I am.
L
L
Ludovic Courtès wrote on 19 Feb 2021 16:14
(name . jbranso--- via Bug reports for GNU Guix)(address . bug-guix@gnu.org)
877dn4m6o0.fsf@gnu.org
Hi Joshua,

jbranso--- via Bug reports for GNU Guix <bug-guix@gnu.org> skribis:

Toggle quote (21 lines)
> Recently on irc, I posted an example of an incorrectly used
> define-record-type* NOT displaying an error line number.
>
> mdevos mentioned that this could potentially be fixed in (guix
> records), but it may also be a guile compile bug as well.
>
> First here is a (guix records) example:
>
> #+BEGIN_SRC scheme
> (use-modules (guix records))
>
> (define-record-type* <sway-bindsym>
> sway-bindsym make-sway-bindsym
> sway-bindsym?
> (key-combo sway-bindsym-key-combo
> (default "")))
>
> (display sway-bindsym) ;; compile error at unknown location
> ;; (display (sway-bindsym)) this is one "correct" way to call this code
> #+END_SRC

Source location info is missing because currently (as of 3.0.5), Guile
keeps location info in the form of “source properties” only for lists.
The ‘sway-bindsym’ symbol above has no associated location info.

This may change in the near future as Andy has been rewriting ‘read’
(the Scheme “parser”) in Scheme, among other things.

Ludo’.
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 46241@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 46241
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch