* Silencing compilation warnings when calling compiler explicitly
@ 2022-08-10 14:42 Jean Abou Samra
2022-08-10 14:46 ` Jean Abou Samra
2022-08-10 16:05 ` Jean Abou Samra
0 siblings, 2 replies; 4+ messages in thread
From: Jean Abou Samra @ 2022-08-10 14:42 UTC (permalink / raw)
To: Guile User
Hi,
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))
(display
(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)
(make-soft-port
(vector
(lambda _ #f) ; output 1 char
(lambda _ #f) ; output string
(lambda () #f) ; flush output
#f ; get char
(lambda () #f) ; close
)
"w"))
(display
(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.
Thanks,
Jean
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Silencing compilation warnings when calling compiler explicitly
2022-08-10 14:42 Silencing compilation warnings when calling compiler explicitly Jean Abou Samra
@ 2022-08-10 14:46 ` Jean Abou Samra
2022-08-10 16:05 ` Jean Abou Samra
1 sibling, 0 replies; 4+ messages in thread
From: Jean Abou Samra @ 2022-08-10 14:46 UTC (permalink / raw)
To: Guile User
Le 10/08/2022 à 16:42, Jean Abou Samra a écrit :
> Hi,
>
> 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))
>
> (display
> (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)
> (make-soft-port
> (vector
> (lambda _ #f) ; output 1 char
> (lambda _ #f) ; output string
> (lambda () #f) ; flush output
> #f ; get char
> (lambda () #f) ; close
> )
> "w"))
Ah, of course, less than a minute after I sent my message, I found
%make-void-port...
Still, is there a better way than playing with the port? I assume I am
doing something wrong, as I would expect #:warning () to work.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Silencing compilation warnings when calling compiler explicitly
2022-08-10 14:42 Silencing compilation warnings when calling compiler explicitly Jean Abou Samra
2022-08-10 14:46 ` Jean Abou Samra
@ 2022-08-10 16:05 ` Jean Abou Samra
2022-08-10 16:14 ` Jean Abou Samra
1 sibling, 1 reply; 4+ messages in thread
From: Jean Abou Samra @ 2022-08-10 16:05 UTC (permalink / raw)
To: Guile User
Le 10/08/2022 à 16:42, Jean Abou Samra a écrit :
> I know that in Guile 3.0 I can do #:warning-level 0,
> and it works,
Correction: no, it does not work (not sure why I thought that).
$ cat x.scm
(use-modules (system base compile))
(display
(compile '(lambda (x)
(case x
((5 5) 5)
((6) 6)))
#:warning-level 0
#:env (current-module)))
$ guile3.0 x.scm
[auto-compilation messages snipped]
;;; <unknown-location>: warning: duplicate datum 5 in clause ((5 5) 5)
of case expression (case x ((5 5) 5) ((6) 6))
#<procedure 555de3e97468 (x)>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Silencing compilation warnings when calling compiler explicitly
2022-08-10 16:05 ` Jean Abou Samra
@ 2022-08-10 16:14 ` Jean Abou Samra
0 siblings, 0 replies; 4+ messages in thread
From: Jean Abou Samra @ 2022-08-10 16:14 UTC (permalink / raw)
To: Guile User
Le 10/08/2022 à 18:05, Jean Abou Samra a écrit :
> Le 10/08/2022 à 16:42, Jean Abou Samra a écrit :
>> I know that in Guile 3.0 I can do #:warning-level 0,
>> and it works,
>
> Correction: no, it does not work (not sure why I thought that).
>
>
> $ cat x.scm
> (use-modules (system base compile))
>
> (display
> (compile '(lambda (x)
> (case x
> ((5 5) 5)
> ((6) 6)))
> #:warning-level 0
> #:env (current-module)))
> $ guile3.0 x.scm
> [auto-compilation messages snipped]
> ;;; <unknown-location>: warning: duplicate datum 5 in clause ((5 5) 5)
> of case expression (case x ((5 5) 5) ((6) 6))
> #<procedure 555de3e97468 (x)>
The same problem exists when compiling code with 'guild compile',
which really looks like a bug, so I'm going to report it.
$ cat cased.scm
(case 5
((5 5) 5))
$ guild3.0 compile -W0 cased.scm
cased.scm:2:3: warning: duplicate datum 5 in clause ((5 5) 5) of case
expression (case 5 ((5 5) 5))
wrote `/[...]/cased.scm.go'
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-08-10 16:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-10 14:42 Silencing compilation warnings when calling compiler explicitly Jean Abou Samra
2022-08-10 14:46 ` Jean Abou Samra
2022-08-10 16:05 ` Jean Abou Samra
2022-08-10 16:14 ` Jean Abou Samra
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).