[Top][All Lists]

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

Silencing compilation warnings when calling compiler explicitly

From: Jean Abou Samra
Subject: Silencing compilation warnings when calling compiler explicitly
Date: Wed, 10 Aug 2022 16:42:48 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0


I'm wondering if there is a simple way to shut up warnings emitted
when calling compile in Guile 2.2. For example:

(use-modules (system base compile))

 (compile '(lambda (x)
             (case x
               ((5 5) 5)
               ((6) 6)))
          #:env (current-module)
          #:opts '(#:warnings ())))

From the code of compile in module/system/base/compile.scm (when
checking out the v2.2.7 tag in the repository), it seems that
the use of #:warning () in opts should turn off warnings, but
this seems not to be the case, as the output is

;;; <unknown-location>: warning: duplicate datum 5 in clause ((5 5) 5) of case expression (case x ((5 5) 5) ((6) 6))
#<procedure 56451d956b58 (x)>

So far, I've found

(use-modules (system base compile))

(define (make-null-port)
    (lambda _ #f) ; output 1 char
    (lambda _ #f) ; output string
    (lambda () #f) ; flush output
    #f ; get char
    (lambda () #f) ; close

 (parameterize ((current-warning-port (make-null-port)))
   (compile '(lambda (x)
               (case x
                 ((5 5) 5)
                 ((6) 6)))
            #:env (current-module))))

This seems a bit heavy-handed, so I'd appreciate if there
is a better way.

I know that in Guile 3.0 I can do #:warning-level 0,
and it works, but this is for LilyPond, which has to
support Guile 2.2 for now.


reply via email to

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