-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Byte compilation warning "the function ‘js2-imenu-extras-setup’ might not be defined at runtime." #1032
Comments
I always have trouble making Other people have issues too, and you might try some of the suggestions in these issues: |
I can reproduce this, too, using |
I see @skangas asking for a minimal reproduce step for this in #636 (comment), I do not byte-compile my init file, but I got those warnings from flycheck, and I'd like to show how to reproduce it:
(use-package rainbow-mode
:functions (rainbow-x-color-luminance)
:config
(rainbow-x-color-luminance "cyan"))
You should get a warning about I also did further investigetion, first this only happens when a file is under I also tried to expand the macro, but in compiling state with the following hack:
Then I got the following result: (progn
(eval-and-compile
(declare-function rainbow-x-color-luminance "rainbow-mode")
(eval-when-compile
(with-demoted-errors "Cannot load rainbow-mode: %S" nil
(unless
(featurep 'rainbow-mode)
(load "rainbow-mode" nil t)))))
(defvar use-package--warning67
#'(lambda
(keyword err)
(let
((msg
(format "%s/%s: %s" 'rainbow-mode keyword
(error-message-string err))))
(display-warning 'use-package msg :error))))
(condition-case-unless-debug err
(if
(not
(require 'rainbow-mode nil t))
(display-warning 'use-package
(format "Cannot load %s" 'rainbow-mode)
:error)
(condition-case-unless-debug err
(progn
(rainbow-x-color-luminance "cyan")
t)
(error
(funcall use-package--warning67 :config err))))
(error
(funcall use-package--warning67 :catch err)))) So So the problem is: we declared the function, but seems not help. Hoping those infomation helpful to you! |
Thanks @AlynxZhou for sharing. Your trick of setting |
See https://github.com/jwiegley/use-package/blob/master/use-package-core.el#L658-L674. Those keywords only exist to make byte-compiler happy, so |
The use-package documentation states:
It appears that this is false in general and there is an error in
This expands to:
The call
by
Please confirm that this fixes the problem for you, and perhaps submit a PR. |
Unfortunately my suggestion causes some runtime cost--- so it's not suitable. For reference, with |
I've kept researching the issue, and I found that this variant is better:
Using it, init time is 0.7s when init.el is interpreted, and 0.35s when it is compiled. I'm not sure what kind of magic is performed by |
With this change, `use-package p` puts in scope all the symbols declared by package p in scope of its :config block. The tradeoff is that init is slightly slower *if interpreted*. Compiling init.el gives the same runtime behaviour as previously. Fixes jwiegley#1032
This simple code:
gives me the byte compilation warning:
I've spent hours but still wasn't able to silence the warning. I'm wondering whether it would be possible to solve it.
The text was updated successfully, but these errors were encountered: