bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#23495: byte-compile-file return t when there is "XXX can't use lexic


From: Yuta Yamada
Subject: bug#23495: byte-compile-file return t when there is "XXX can't use lexical var" error
Date: Wed, 11 May 2016 07:33:59 -0700 (PDT)

Michael Heerdegen <michael_heerdegen@web.de> writes:

> > Seems it's wanted.  The compiler calls `byte-compile-log-warning' in
> > this case, which, unlike `byte-compile-warn', circumvents
> > `byte-compile-error-on-warn'.

> I wonder if we could/should call `byte-compile-warn' instead.

I found this web page (sorry if you already knew):
https://www.gnu.org/software/emacs/manual/html_node/elisp/Warning-Basics.html

And it describes:

"If you want to take the trouble to implement a way to continue
processing despite the bad data, then reporting a warning of severity
:error is the right way to inform the user of the problem. For
instance, the Emacs Lisp byte compiler can report an error that way
and continue compiling other functions. (If the program signals a Lisp
error and then handles it with condition-case, the user won ’ t see the
error message; it could show the message to the user by reporting it
as a warning.)"

So, seems there is an intent about this warning.

> But Yuta, please tell me about your use case.  A lot of other warnings
> printed while byte compiling can hint to similarly serious mistakes in
> the code.

> Would changing the behavior of this particular case really make things
> better?  Can't you just have a look at the compiler warnings, which is a
> good idea (necessary) anyway?

When I write elisp code myself, current behavior is ok. I can see the
pseudo error (or warning) message from flycheck/flymake, but when I
review other people's elisp codes on GitHub, I'm using Travis to check
byte compile warnings or errors and if tests are passed, I expects
there is no byte compile errors and I normally don't check build
result. (I think other elisp package maintainers too.)

For example, this is a build result when I noticed this error:
https://travis-ci.org/nim-lang/nim-mode/jobs/126456294

There are many noises to check errors and warnings and I'm hoping
returning non-zero status code in this case, so I can reduce the
chance to see the build result. (even this is a warning,
"Error: ..." sentence made me imagine I got an error...)


I understood that treating this warning as error hides other byte
compile warnings, so how about adding extra code to
`byte-compile-log-warning` function or make new function for this type
of warning that emits "Error: ...." message, but actually it's a warning?

----
(defun byte-compile-log-warning (string &optional fill level)
  (let ((warning-prefix-function 'byte-compile-warning-prefix)
        (warning-type-format "")
        (warning-fill-prefix (if fill "    ")))
    (display-warning 'bytecomp string level byte-compile-log-buffer)
    ;; I added below code
    ;; the `byte-compiler-error-flag' changes final result of
    ;; byte-compile-file.
    (when (or byte-compile-error-on-warn (eq level :error))
      (setq byte-compiler-error-flag t))))
----


Thanks

Yuta

reply via email to

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