* esup byte compile warnings
@ 2020-01-24 20:48 Serghei Iakovlev
2020-01-24 21:55 ` Stefan Monnier
0 siblings, 1 reply; 5+ messages in thread
From: Serghei Iakovlev @ 2020-01-24 20:48 UTC (permalink / raw)
To: GNU Emacs Developers
Hello,
There are `esup' [1] byte compile warnings I would like avoid to.
Some of them seems trivial to me. However, I don't quite understand
slots related warnings. In general I would like to realize on how
to deal with such kind of warnings and I need help. In fact, I
often come across something similar and I'll appreciate it if you
help me deal with such warnings.
N.B. This happens in Emacs 28.0.50 as well as in 27.0.60
[1]: https://github.com/jschaf/esup/issues/68
--
Serghei
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: esup byte compile warnings
2020-01-24 20:48 esup byte compile warnings Serghei Iakovlev
@ 2020-01-24 21:55 ` Stefan Monnier
2020-01-29 12:56 ` Serghei Iakovlev
0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2020-01-24 21:55 UTC (permalink / raw)
To: Serghei Iakovlev; +Cc: GNU Emacs Developers
> There are `esup' [1] byte compile warnings I would like avoid to.
> Some of them seems trivial to me. However, I don't quite understand
> slots related warnings.
The the slots, usually it's just that code that uses EIEIO seems to
misuse a weird feature of EIEIO, so they use the initval keyword instead
of the slot name when accessing the slot. For example, often code will
do
(slot-value x :file)
where the slot's name is not `:file` but `file`, so the correct usage is
(slot-value x 'file)
This odd usage does work for historical reasons but is deprecated, hence
the warning.
Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: esup byte compile warnings
2020-01-24 21:55 ` Stefan Monnier
@ 2020-01-29 12:56 ` Serghei Iakovlev
2020-01-29 14:32 ` Stefan Monnier
0 siblings, 1 reply; 5+ messages in thread
From: Serghei Iakovlev @ 2020-01-29 12:56 UTC (permalink / raw)
To: Stefan Monnier; +Cc: GNU Emacs Developers
I've replaced all the ‘oref’ with ‘slot-value’ and properly used
quotes for the slot names. Thus, I've replaced
(oref x :y)
by
(slot-value x 'y)
This seems is works, but still there are some warnings remaining.
For example:
In esup-total-exec-time:
esup.el:166:52: Warning: Unknown slot ‘exec-time’
In esup-total-gc-number:
esup.el:172:52: Warning: Unknown slot ‘gc-number’
In esup-total-gc-time:
esup.el:178:50: Warning: Unknown slot ‘gc-time’
In esup-drop-insignificant-times:
esup.el:186:39: Warning: Unknown slot ‘exec-time’
esup.el:530:25: Warning: Unknown slot ‘file’
esup.el:538:9: Warning: Unknown slot ‘start-point’
esup.el:545:30: Warning: Unknown slot ‘line-number’
esup.el:548:30: Warning: Unknown slot ‘exec-time’
esup.el:546:30: Warning: Unknown slot ‘percentage’
esup.el:549:30: Warning: Unknown slot ‘expression-string’
In esup-fontify-results:
esup.el:560:15: Warning: Unknown slot ‘expression-string’
Consider the following defun:
(defun esup-total-exec-time (results)
"Calculate the total execution time of RESULTS."
(cl-loop for result in results
sum (slot-value result 'exec-time) into total-exec-time
finally return total-exec-time))
This produces a waring:
In esup-total-exec-time:
esup.el:166:52: Warning: Unknown slot ‘exec-time’
Looks like the reason is that the byte-compiler unable to match
‘result’ with the class declaration.
I found similar [1] issues [2], but I'm still not pretty sure the
proper way to fix these warnings.
[1]: https://lists.gnu.org/archive/html/emacs-devel/2017-01/msg00678.html
[2]: https://lists.gnu.org/archive/html/emacs-devel/2016-02/msg00880.html
> On 24 Jan 2020, at 23:55, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>
>
>> There are `esup' [1] byte compile warnings I would like avoid to.
>> Some of them seems trivial to me. However, I don't quite understand
>> slots related warnings.
>
> The the slots, usually it's just that code that uses EIEIO seems to
> misuse a weird feature of EIEIO, so they use the initval keyword instead
> of the slot name when accessing the slot. For example, often code will
> do
>
> (slot-value x :file)
>
> where the slot's name is not `:file` but `file`, so the correct usage is
>
> (slot-value x 'file)
>
> This odd usage does work for historical reasons but is deprecated, hence
> the warning.
>
>
> Stefan
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: esup byte compile warnings
2020-01-29 12:56 ` Serghei Iakovlev
@ 2020-01-29 14:32 ` Stefan Monnier
2020-01-29 14:42 ` Serghei Iakovlev
0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2020-01-29 14:32 UTC (permalink / raw)
To: Serghei Iakovlev; +Cc: GNU Emacs Developers
> Consider the following defun:
>
> (defun esup-total-exec-time (results)
> "Calculate the total execution time of RESULTS."
> (cl-loop for result in results
> sum (slot-value result 'exec-time) into total-exec-time
> finally return total-exec-time))
>
> This produces a waring:
>
> In esup-total-exec-time:
> esup.el:166:52: Warning: Unknown slot ‘exec-time’
This warning means that the bytecompiler has not seen any `defclass`
that defines a slot `exec-time`. Maybe it's perfectly normal (you know
that the object will indeed have an `exec-time` slot when that code will
be executed), e.g. because the object will be created in another file
which is not `require`d in this file, but without knowing more about
this slot it's hard to tell what's the best way to address the warning.
[...looking at https://github.com/jschaf/esup...]
Oh, I think it's because of
(let ((load-path (append load-path (list esup-load-path))))
(require 'esup-child))
which means that the `require` won't be executed by the byte-compiler
(because it's within a `let`). Either you should just drop this
`load-path` trickery (and push the responsability of `load-path`
manipulation to the code that byte-compiles the files, as usual), or you
may want to wrap this within an `eval-and-compile`.
> Looks like the reason is that the byte-compiler unable to match
> ‘result’ with the class declaration.
The compiler doesn't even try to infer types. It only checks that some
class somewhere has defined a slot of that name (that's good enough to
catch most typos).
Stefan
PS: While I'm here I noticed:
(eval-when-compile
(if (and (<= emacs-major-version 24)
(<= emacs-minor-version 3))
(require 'cl)
(require 'cl-lib)))
which makes no sense: those two libraries provide the same *kind* of
functionality, but under completely different names. The rest of the
code uses things like `cl-loop`, so you need to (require 'cl-lib)
because that's what the code uses. In Emacs<24.4, `cl-lib` will itself
load `cl` (because it uses it internally, but that's an implementation
detail).
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: esup byte compile warnings
2020-01-29 14:32 ` Stefan Monnier
@ 2020-01-29 14:42 ` Serghei Iakovlev
0 siblings, 0 replies; 5+ messages in thread
From: Serghei Iakovlev @ 2020-01-29 14:42 UTC (permalink / raw)
To: Stefan Monnier; +Cc: GNU Emacs Developers
> Oh, I think it's because of
>
> (let ((load-path (append load-path (list esup-load-path))))
> (require 'esup-child))
>
Good catch! Thank you. Actually I planned to remove this earlier
but didn't noticed this relation.
> PS: While I'm here I noticed:
>
> (eval-when-compile
> (if (and (<= emacs-major-version 24)
> (<= emacs-minor-version 3))
> (require 'cl)
> (require 'cl-lib)))
>
> which makes no sense: those two libraries provide the same *kind* of
> functionality, but under completely different names. The rest of the
> code uses things like `cl-loop`, so you need to (require 'cl-lib)
> because that's what the code uses. In Emacs<24.4, `cl-lib` will itself
> load `cl` (because it uses it internally, but that's an implementation
> detail).
>
Yes, this is fixed in the separated branch (‘byte-war’) which I have
not yet merged into master.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-01-29 14:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-01-24 20:48 esup byte compile warnings Serghei Iakovlev
2020-01-24 21:55 ` Stefan Monnier
2020-01-29 12:56 ` Serghei Iakovlev
2020-01-29 14:32 ` Stefan Monnier
2020-01-29 14:42 ` Serghei Iakovlev
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.