[Top][All Lists]

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

Re: [PATCH] Print backtraces for syntax errors too.

From: Maxime Devos
Subject: Re: [PATCH] Print backtraces for syntax errors too.
Date: Thu, 23 Feb 2023 20:27:07 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.0

On 23-02-2023 12:38, Ludovic Courtès wrote:

Maxime Devos <> skribis:

For complicated macros, especially macros that are used correctly but
have a bug in their implementation somewhere and use 'syntax-case'
or 'syntax-rules' multiple times, it can be very convenient to know
_which_ syntax-case or syntax-rules raised the syntax-error.

E.g., I'm currently debugging some changes to a (non-Guile) macro,
and I don't know what to make of the following -- the '#:getter . datum-type'
isn't even present in the original code anywhere:

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Syntax error:
unknown location: source expression failed to match any pattern in form 
(#:getter . datum-type)
make: *** [Makefile:1333: gnu/gnunet/dht/client.go] Fout 1

As such, partially revert the following commit that does not give a
rationale on how backtraces for syntax errors aren't helpful.

Do you have a simple reproducer and a before/after comparison showing
what Guile prints?

Looks like the patch didn't actually work:

(define-syntax syntax-stuff-twice
  (lambda (s)
    (define (process/internal object)
      ;; Oops! Only certain forms of 'object' were accepted.
      (throw 'syntax-error "syntax-stuff-twice" "bad" '() object object))
    (define (process/x x)
      #`(list #,(process/internal x)))
    (define (process/y y)
      #`(vector #,(process/internal y)))
    (define (computify o)
      (datum->syntax #false o))
    (syntax-case s ()
       ;; Let's compute some syntax, for some reason.
       (let ((x (computify "imagine this syntax is very hard to follow"))
             (y (computify "and difficult to distinguish from this")))
         #`(list #,(process/x x) #,(process/y y)))))))


;; Before:
;; unknown file:#f:#f: syntax-stuff-twice: bad in subform #<syntax:reproducer.scm:15:27 "imagine this syntax is very hard to follow"> of #<syntax:reproducer.scm:15:27 "imagine this syntax is very hard to follow">
;; After:
;;  [the same thing]
;; Looks like another patch is needed ...

Attachment: OpenPGP_0x49E3EE22191725EE.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

reply via email to

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