unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#46958: 28.0.50; invalid-function error for macros that have function bindings
@ 2021-03-06  2:00 Robert Irelan
  2021-03-06 12:55 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 14+ messages in thread
From: Robert Irelan @ 2021-03-06  2:00 UTC (permalink / raw)
  To: 46958

Lately I have been getting errors where occasionally `invalid-function`
errors will be raised when calling some macros, even when those macros
have function bindings (checked with `fboundp`). Here is an example of a
stack trace I got when using the `org-fc` package:

```
Debugger entered--Lisp error: (invalid-function
org-fc-with-point-at-back-heading)
  signal(invalid-function (org-fc-with-point-at-back-heading))
  (condition-case err (if org-fc--session (let* ((card (and t
(eieio-oref org-fc--session 'current-item)))) (if card (if (string=
(plist-get card :id) (org-id-get)) (progn (let ((type (plist-get card
:type))) (funcall (org-fc-type-flip-fn type))
(org-fc-review-rate-mode))) (message "Flashcard ID mismatch"))
(message "No flashcard review is in progress")))) (error
(org-fc-review-quit) (signal (car err) (cdr err))))
  org-fc-review-flip()
  funcall-interactively(org-fc-review-flip)
  call-interactively(org-fc-review-flip nil nil)
  command-execute(org-fc-review-flip)
 ```

I am using the nativecomp variant of Emacs 28.0.50 at Git commit
80e26472206cc44837521ba594cd50e724d9af5c, compiled using the following
Macports Port (the "emacs-app-devel" Port):

https://github.com/macports/macports-ports/blob/0c3c5e770185f4c3577b94a49170a961b88d1b98/editors/emacs/Portfile#L100-L141

Configured using:
 'configure --prefix=/opt/local --disable-silent-rules --without-dbus
 --without-gconf --without-libotf --without-m17n-flt --with-gmp
 --with-gnutls --with-json --with-xml2 --with-modules --infodir
 /opt/local/share/info/emacs --with-ns --with-lcms2 --without-harfbuzz
 --without-xaw3d --with-nativecomp --with-imagemagick --with-rsvg
 'CFLAGS=-pipe -Os
 -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk
 -arch x86_64' 'CPPFLAGS=-I/opt/local/include
 -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk'
 'LDFLAGS=-L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-no_pie
 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk
 -arch x86_64''

Configured features:
JPEG TIFF GIF PNG RSVG IMAGEMAGICK GLIB NOTIFY KQUEUE ACL GNUTLS LIBXML2
ZLIB TOOLKIT_SCROLL_BARS XIM NS MODULES NATIVE_COMP THREADS JSON PDUMPER
LCMS2

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8

Major mode: Org

Minor modes in effect:
  diff-hl-margin-mode: t
  global-anzu-mode: t
  anzu-mode: t
  straight-use-package-mode: t
  evil-traces-mode: t
  which-key-mode: t
  better-jumper-mode: t
  better-jumper-local-mode: t
  global-company-mode: t
  company-mode: t
  ivy-rich-project-root-cache-mode: t
  ivy-rich-mode: t
  ivy-mode: t
  evil-goggles-mode: t
  evil-escape-mode: t
  evil-snipe-override-mode: t
  evil-snipe-mode: t
  evil-snipe-override-local-mode: t
  evil-snipe-local-mode: t
  whitespace-mode: t
  git-auto-commit-mode: t
  evil-org-mode: t
  savehist-mode: t
  git-gutter-mode: t
  projectile-mode: t
  flycheck-popup-tip-mode: t
  eros-mode: t
  gcmh-mode: t
  winner-mode: t
  smartparens-global-mode: t
  smartparens-mode: t
  global-flycheck-mode: t
  flycheck-mode: t
  ws-butler-global-mode: t
  ws-butler-mode: t
  editorconfig-mode: t
  recentf-mode: t
  save-place-mode: t
  global-so-long-mode: t
  envrc-mode: t
  solaire-global-mode: t
  solaire-mode: t
  doom-modeline-mode: t
  display-fill-column-indicator-mode: t
  vi-tilde-fringe-mode: t
  display-line-numbers-mode: t
  yas-minor-mode: t
  org-super-agenda-mode: t
  override-global-mode: t
  global-git-commit-mode: t
  org-roam-mode: t
  adaptive-wrap-prefix-mode: t
  auto-compile-on-load-mode: t
  auto-compile-on-save-mode: t
  persp-mode: t
  ns-auto-titlebar-mode: t
  shell-dirtrack-mode: t
  evil-mode: t
  evil-local-mode: t
  +popup-mode: t
  general-override-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  window-divider-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  size-indication-mode: t
  column-number-mode: t
  line-number-mode: t
  global-visual-line-mode: t
  visual-line-mode: t
  transient-mark-mode: t

Load-path shadows:
/Users/rmirelan/doom.emacs.d/.local/straight/build-28.0.50/cmake-mode/cmake-mode
hides /opt/local/share/emacs/site-lisp/cmake-mode
/Users/rmirelan/doom.emacs.d/.local/straight/build-28.0.50/map/map
hides /Applications/MacPorts/Emacs.app/Contents/Resources/lisp/emacs-lisp/map
/Users/rmirelan/doom.emacs.d/.local/straight/build-28.0.50/dash-functional/dash-functional
hides /Users/rmirelan/.doom.d/emacs-google-config/third_party/elisp/dash/dash-functional
/Users/rmirelan/doom.emacs.d/.local/straight/build-28.0.50/dash/dash
hides /Users/rmirelan/.doom.d/emacs-google-config/third_party/elisp/dash/dash
/Users/rmirelan/doom.emacs.d/.local/straight/build-28.0.50/s/s hides
/Users/rmirelan/.doom.d/emacs-google-config/third_party/elisp/s/s

Features:
(shadow sort mail-extr emacsbug sendmail elisp-def ert
evil-collection-debug debug org-duration org-crypt dabbrev magit-extras
evil-markdown smartparens-markdown markdown-mode edit-indirect tabify
company-ispell company-yasnippet company-dabbrev vc-hg vc-svn
bug-reference diff-hl-margin diff-hl-dired diff-hl
evil-collection-log-view log-view evil-collection-vc-dir vc-dir ewoc
goto-addr magit-gitflow elisp-demos evil-collection-indent
hide-mode-line evil-collection-helpful helpful trace
evil-collection-edebug edebug info-look dash-functional
evil-collection-elisp-refs elisp-refs evil-anzu anzu overseer pkg-info
lisp-mnt epl tramp tramp-loaddefs trampver tramp-integration files-x
tramp-compat ls-lisp amx evil-visual-mark-mode-autoloads
hl-line+-autoloads pocket-reader-autoloads org-super-agenda-autoloads
org-randomnote-autoloads org-ql-autoloads org-journal-autoloads
org-drill-table-autoloads org-gcal-autoloads alert-autoloads
org-fc-autoloads org-clock-csv-autoloads git-auto-commit-mode-autoloads
rainbow-identifiers-autoloads vimrc-mode-autoloads rg-autoloads
auto-compile-autoloads call-log-autoloads link-hint-autoloads
drag-stuff-autoloads yaml-mode-autoloads counsel-css-autoloads
rainbow-mode-autoloads sws-mode-autoloads stylus-mode-autoloads
sass-mode-autoloads company-web-autoloads web-mode-autoloads
slim-mode-autoloads pug-mode-autoloads haml-mode-autoloads
emmet-mode-autoloads company-shell-autoloads racer-autoloads
rustic-autoloads raku-mode-autoloads py-isort-autoloads
pyimport-autoloads python-pytest-autoloads pyvenv-autoloads
pipenv-autoloads company-anaconda-autoloads anaconda-mode-autoloads
pip-requirements-autoloads ox-hugo-autoloads ox-pandoc-autoloads
ob-async-autoloads org-roam-autoloads org-re-reveal-autoloads
org-tree-slide-autoloads centered-window-autoloads
org-pomodoro-autoloads jupyter-autoloads org-download-autoloads
orgit-autoloads org-pdftools-autoloads evil-org-autoloads
org-cliplink-autoloads toc-org-autoloads ox-clip-autoloads
htmlize-autoloads avy-autoloads org-mode-autoloads
company-nixos-options-autoloads nix-mode-autoloads
evil-markdown-autoloads edit-indirect-autoloads markdown-toc-autoloads
markdown-mode-autoloads company-math-autoloads company-reftex-autoloads
company-auctex-autoloads evil-tex-autoloads latex-preview-pane-autoloads
adaptive-wrap-autoloads auctex-autoloads xref-js2-autoloads
tide-autoloads skewer-mode-autoloads nodejs-repl-autoloads
add-node-modules-path-autoloads npm-mode-autoloads
js2-refactor-autoloads typescript-mode-autoloads rjsx-mode-autoloads
js2-mode-autoloads coffee-mode-autoloads meghanada-autoloads
groovy-mode-autoloads android-mode-autoloads
flycheck-golangci-lint-autoloads company-go-autoloads
go-gen-test-autoloads go-tag-autoloads gorepl-mode-autoloads
go-mode-autoloads go-guru-autoloads go-eldoc-autoloads
buttercup-autoloads flycheck-cask-autoloads elisp-demos-autoloads
elisp-def-autoloads overseer-autoloads macrostep-autoloads
highlight-quoted-autoloads csv-mode-autoloads rtags-autoloads
company-irony-c-headers-autoloads company-irony-autoloads
flycheck-irony-autoloads irony-eldoc-autoloads irony-autoloads
glsl-mode-autoloads opencl-mode-autoloads modern-cpp-font-lock-autoloads
disaster-autoloads demangle-mode-autoloads cuda-mode-autoloads
cmake-mode-autoloads pdf-tools-autoloads makefile-executor-autoloads
github-review-autoloads magit-todos-autoloads magit-gitflow-autoloads
lsp-ivy-autoloads lsp-ui-autoloads lsp-mode-autoloads ivy-xref-autoloads
dumb-jump-autoloads eros-autoloads quickrun-autoloads
editorconfig-autoloads envrc-autoloads ns-auto-titlebar-autoloads
osx-trash-autoloads flycheck-popup-tip-autoloads flycheck-autoloads
gitignore-mode-autoloads gitconfig-mode-autoloads
git-timemachine-autoloads browse-at-remote-autoloads fd-dired-autoloads
dired-rsync-autoloads diff-hl-autoloads dired-git-info-autoloads
diredfl-autoloads doom-snippets-autoloads auto-yasnippet-autoloads
parinfer-autoloads evil-vimish-fold-autoloads vimish-fold-autoloads
yasnippet-autoloads evil-collection-autoloads evil-quick-diff-autoloads
evil-visualstar-autoloads evil-traces-autoloads
evil-textobj-anyblock-autoloads evil-surround-autoloads
evil-snipe-autoloads evil-numbers-autoloads
evil-nerd-commenter-autoloads evil-lion-autoloads
evil-indent-plus-autoloads evil-exchange-autoloads evil-escape-autoloads
evil-embrace-autoloads evil-easymotion-autoloads evil-args-autoloads
evil-autoloads persp-mode-autoloads ace-window-autoloads
vi-tilde-fringe-autoloads evil-goggles-autoloads nav-flash-autoloads
hl-todo-autoloads solaire-mode-autoloads doom-themes-autoloads
anzu-autoloads doom-modeline-autoloads wgrep-autoloads
ivy-rich-autoloads counsel-projectile-autoloads amx-autoloads
counsel-autoloads ivy-autoloads swiper-autoloads company-dict-autoloads
company-autoloads which-key-autoloads general-autoloads
projectile-autoloads ws-butler-autoloads pcre2el-autoloads
helpful-autoloads dtrt-indent-autoloads better-jumper-autoloads
restart-emacs-autoloads rainbow-delimiters-autoloads
highlight-numbers-autoloads hide-mode-line-autoloads
all-the-icons-autoloads explain-pause-mode-autoloads gcmh-autoloads
auto-minor-mode-autoloads finder-inf use-package-autoloads
bind-key-autoloads straight-autoloads evil-collection-info info straight
char-fold help-fns radix-tree cl-print backtrace evil-collection-help
help mc-hide-unmatched-lines-mode mc-mark-more mc-cycle-cursors
multiple-cursors-core cursor-sensor evil-collection-minibuffer
evil-traces evil-ex evil-collection-which-key which-key better-jumper
company-capf company evil-collection-ivy ivy-avy avy ivy-rich counsel
xdg ivy-xref evil-collection-xref xref project swiper ivy delsel
ivy-faces ivy-overlay colir evil-goggles evil-easymotion evil-escape
evil-snipe auto-minor-mode whitespace git-auto-commit-mode org-eldoc
embrace expand-region text-mode-expansions the-org-mode-expansions
er-basic-expansions expand-region-core expand-region-custom toc-org
evil-org image-file image-converter lv savehist git-gutter-fringe
fringe-helper git-gutter evil-collection-vc-git vc-git projectile
flycheck-popup-tip evil-collection-popup popup flycheck-cask
parinfer-ext parinfer evil-collection-ediff ediff mode-local parinferlib
eros highlight-quoted rainbow-delimiters highlight-numbers parent-mode
rainbow-identifiers color raku-detect face-remap editorconfig-core
editorconfig-core-handle editorconfig-fnmatch gcmh winner paren
smartparens-config smartparens-text smartparens evil-collection-flycheck
flycheck ws-butler editorconfig recentf tree-widget saveplace so-long
envrc inheritenv nav-flash pulse jka-compr doom-themes-ext-org
solaire-mode doom-one-light-theme doom-themes doom-themes-base
doom-modeline doom-modeline-segments doom-modeline-env
doom-modeline-core shrink-path all-the-icons all-the-icons-faces
data-material data-weathericons data-octicons data-fileicons
data-faicons data-alltheicons display-fill-column-indicator
vi-tilde-fringe display-line-numbers doom-snippets doom-snippets-lib
yasnippet evil-collection-elisp-mode elisp-mode dtrt-indent ol-bibtex
bibtex .emacs org-buganizer google-bugged org-p4 p4-files google-process
aio google-paths google-platform sql evil-collection-view view
google-emacs-utilities ediff-merg ediff-mult ediff-wind ediff-diff
ediff-help ediff-util ediff-init org-super-agenda ts ht inline org-habit
org-inlinetask org-roam-protocol org-protocol use-package-bind-key
bind-key org-fc org-fc-cache org-fc-dashboard org-fc-algo-sm2 cl
org-fc-type-cloze org-fc-type-text-input org-fc-type-double
org-fc-type-normal org-fc-awk org-fc-compat svg dom parse-time iso8601
org-indent org-drill persist org-agenda orgit
evil-collection-magit-todos magit-todos pcre2el rxt re-builder hl-todo
async github-review ghub-graphql treepy gsexp ghub url-http url-gw nsm
url-auth gnutls deferred a magit-autoloads magit-submodule
magit-obsolete magit-popup magit-blame magit-stash magit-reflog
magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote
magit-commit magit-sequence magit-notes magit-worktree magit-tag
magit-merge magit-branch magit-reset magit-files magit-refs magit-status
magit core-packages package browse-url url url-proxy url-privacy
url-expand url-methods url-history url-cookie url-domsuf url-util
mailcap url-handlers magit-repos magit-apply magit-wip magit-log
which-func evil-collection-imenu imenu magit-diff smerge-mode diff
evil-collection-diff-mode diff-mode git-commit evil-collection-log-edit
log-edit message rmc puny rfc822 mml mml-sec evil-collection-epa epa epg
epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode
mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr
mailabbrev mail-utils gmm-utils mailheader pcvs-util add-log magit-core
magit-autorevert autorevert filenotify magit-margin magit-transient
magit-process with-editor evil-collection-term term disp-table ehelp
evil-collection-eshell em-prompt esh-mode eshell esh-cmd esh-ext esh-opt
esh-proc esh-io esh-arg esh-module esh-groups esh-util
evil-collection-dired dired dired-loaddefs server magit-mode help-mode
magit-git magit-section magit-utils crm org-roam org-roam-link
org-roam-graph xml org-roam-doctor org-roam-dailies org-roam-capture
org-roam-db emacsql-sqlite3 emacsql emacsql-compiler org-capture
org-roam-completion org-roam-buffer org-roam-faces org-roam-macs
org-roam-compat f s dash org-id org-refile smartparens-org org-yt
org-element avl-tree generator org ob ob-tangle ob-ref ob-lob ob-table
ob-exp org-macro org-footnote org-src ob-comint org-pcomplete org-list
org-faces org-entities time-date noutline outline org-version
ob-emacs-lisp ob-core ob-eval org-table ol org-keys org-compat org-macs
org-loaddefs find-func evil-collection-calendar cal-menu calendar
cal-loaddefs adaptive-wrap evil-collection-explain-pause-mode
explain-pause-mode explain-pause-top explain-pause-log-to-socket
evil-collection-profiler profiler hl-line+ hl-line evil-collection-rg rg
vc vc-dispatcher rg-info-hack rg-menu transient format-spec rg-ibuffer
rg-result wgrep-rg evil-collection-wgrep wgrep rg-history rg-header
ibuf-ext evil-collection-ibuffer ibuffer ibuffer-loaddefs
evil-collection-grep grep evil-collection-compile compile
text-property-search auto-compile packed evil-collection-custom cus-edit
cus-start cus-load wid-edit evil-collection-comint evil-collection
annalist persp-mode let-alist ns-auto-titlebar evil evil-integration
evil-maps evil-commands ffap url-parse auth-source eieio eieio-core
eieio-loaddefs password-cache json map url-vars reveal flyspell ispell
evil-jumps evil-command-window evil-types evil-search shell pcomplete
comint ansi-color evil-macros evil-repeat evil-states evil-core advice
evil-common windmove thingatpt rect evil-digraphs evil-vars ring
easy-mmode derived core-editor core-projects core-ui edmacro kmacro comp
comp-cstr warnings rx core-keybinds pp general cl-extra easymenu seq
byte-opt cl-seq use-package-core bytecomp byte-compile cconv
core-modules tex-site core core-lib cl-macs gv cl-loaddefs cl-lib subr-x
iso-transl tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/ns-win ns-win ucs-normalize mule-util
term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch timer select scroll-bar mouse
jit-lock font-lock syntax facemenu font-core term/tty-colors frame
minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite charscript charprop case-table epa-hook jka-cmpr-hook simple
abbrev obarray cl-preloaded nadvice button loaddefs faces cus-face pcase
macroexp files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget hashtable-print-readable backquote threads
kqueue cocoa ns lcms2 multi-tty make-network-process nativecomp emacs)

Memory information:
((conses 16 1524294 1845224)
 (symbols 48 62411 7)
 (strings 32 243889 240300)
 (string-bytes 1 9782634)
 (vectors 16 98776)
 (vector-slots 8 2645548 1462575)
 (floats 8 1295 10854)
 (intervals 56 39395 14863)
 (buffers 984 39))


-- 
Robert Irelan
rirelan@gmail.com





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#46958: 28.0.50; invalid-function error for macros that have function bindings
  2021-03-06  2:00 bug#46958: 28.0.50; invalid-function error for macros that have function bindings Robert Irelan
@ 2021-03-06 12:55 ` Lars Ingebrigtsen
  2021-03-06 14:24   ` Basil L. Contovounesios
  2021-03-07 14:33   ` Pip Cet
  0 siblings, 2 replies; 14+ messages in thread
From: Lars Ingebrigtsen @ 2021-03-06 12:55 UTC (permalink / raw)
  To: Robert Irelan; +Cc: 46958

Robert Irelan <rirelan@gmail.com> writes:

> Lately I have been getting errors where occasionally `invalid-function`
> errors will be raised when calling some macros, even when those macros
> have function bindings (checked with `fboundp`). Here is an example of a
> stack trace I got when using the `org-fc` package:
>
> ```
> Debugger entered--Lisp error: (invalid-function
> org-fc-with-point-at-back-heading)
>   signal(invalid-function (org-fc-with-point-at-back-heading))

I'm not quite sure I understand this bug report.  First of all,
`org-fc-with-point-at-back-heading' doesn't seem to exist in the Emacs
tree, so is this from an external package?

The other issue is that I think there's a misunderstanding here: You can
never funcall a macro.

(macrop 'when)
=> t
(fboundp 'when)
=> t
(funcall 'when)
=> Debugger entered--Lisp error: (invalid-function when)
    when()

Macros are foundp, but that doesn't mean you can funcall them.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#46958: 28.0.50; invalid-function error for macros that have function bindings
  2021-03-06 12:55 ` Lars Ingebrigtsen
@ 2021-03-06 14:24   ` Basil L. Contovounesios
  2021-03-06 18:28     ` Robert Irelan
  2021-03-07 14:33   ` Pip Cet
  1 sibling, 1 reply; 14+ messages in thread
From: Basil L. Contovounesios @ 2021-03-06 14:24 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Robert Irelan, 46958

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Robert Irelan <rirelan@gmail.com> writes:
>
>> Lately I have been getting errors where occasionally `invalid-function`
>> errors will be raised when calling some macros, even when those macros
>> have function bindings (checked with `fboundp`). Here is an example of a
>> stack trace I got when using the `org-fc` package:
>>
>> ```
>> Debugger entered--Lisp error: (invalid-function
>> org-fc-with-point-at-back-heading)
>>   signal(invalid-function (org-fc-with-point-at-back-heading))
>
> I'm not quite sure I understand this bug report.  First of all,
> `org-fc-with-point-at-back-heading' doesn't seem to exist in the Emacs
> tree, so is this from an external package?

Yes:

  https://sr.ht/~l3kn/org-fc/
  https://github.com/l3kn/org-fc

See also: https://todo.sr.ht/~l3kn/org-fc/23

> The other issue is that I think there's a misunderstanding here: You can
> never funcall a macro.
>
> (macrop 'when)
> => t
> (fboundp 'when)
> => t
> (funcall 'when)
> => Debugger entered--Lisp error: (invalid-function when)
>     when()
>
> Macros are foundp, but that doesn't mean you can funcall them.

Just to add: macros are fboundp but not functionp, which is the property
that funcall requires.

The funcall is here:

  https://git.sr.ht/~l3kn/org-fc/tree/main/item/org-fc.el#L1284

Looks like something put something in org-fc-types (e.g. using
org-fc-register-type) that shouldn't be there.

So, this doesn't seem related to Emacs, unless there's been a recent
nativecomp regression that gave rise to this?

HTH,

-- 
Basil





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#46958: 28.0.50; invalid-function error for macros that have function bindings
  2021-03-06 14:24   ` Basil L. Contovounesios
@ 2021-03-06 18:28     ` Robert Irelan
  2021-03-06 22:39       ` Phil Sainty
  0 siblings, 1 reply; 14+ messages in thread
From: Robert Irelan @ 2021-03-06 18:28 UTC (permalink / raw)
  To: Basil L. Contovounesios; +Cc: Lars Ingebrigtsen, 46958

On Sat, Mar 6, 2021 at 6:24 AM Basil L. Contovounesios <contovob@tcd.ie> wrote:

> Just to add: macros are fboundp but not functionp, which is the property
> that funcall requires.
>
> The funcall is here:
>
>   https://git.sr.ht/~l3kn/org-fc/tree/main/item/org-fc.el#L1284
>
> Looks like something put something in org-fc-types (e.g. using
> org-fc-register-type) that shouldn't be there.
>
> So, this doesn't seem related to Emacs, unless there's been a recent
> nativecomp regression that gave rise to this?

The call that's actually failing is located here:
https://git.sr.ht/~l3kn/org-fc/tree/711511192c62f6dccc96644dcf0705fda99e753a/item/org-fc-type-normal.el#L41.
As you can see, we're not trying to funcall a macro here, but it fails
anyway. Moreover, the macro is actually defined in my environment, and
if I run the code that's failing directly in the buffer using M-:, I
get no errors, `invalid-function` or otherwise. Is there a way a macro
might be defined in my "main" environment, so to speak, but not be
defined when being called from another function? As far as I can tell,
there are no weird `letf` shenanigans going on.

-- 
Robert Irelan
rirelan@gmail.com





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#46958: 28.0.50; invalid-function error for macros that have function bindings
  2021-03-06 18:28     ` Robert Irelan
@ 2021-03-06 22:39       ` Phil Sainty
  2021-03-07 14:27         ` Basil L. Contovounesios
  2021-03-07 21:38         ` Robert Irelan
  0 siblings, 2 replies; 14+ messages in thread
From: Phil Sainty @ 2021-03-06 22:39 UTC (permalink / raw)
  To: Robert Irelan; +Cc: Basil L. Contovounesios, Lars Ingebrigtsen, 46958

On 7/03/21 7:28 am, Robert Irelan wrote:
> The call that's actually failing is located here:
> https://git.sr.ht/~l3kn/org-fc/tree/711511192c62f6dccc96644dcf0705fda99e753a/item/org-fc-type-normal.el#L41.

It looks like org-fc-type-normal.el should (require 'org-fc)
at the start.

Does that fix the problem?






^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#46958: 28.0.50; invalid-function error for macros that have function bindings
  2021-03-06 22:39       ` Phil Sainty
@ 2021-03-07 14:27         ` Basil L. Contovounesios
  2021-03-07 21:38         ` Robert Irelan
  1 sibling, 0 replies; 14+ messages in thread
From: Basil L. Contovounesios @ 2021-03-07 14:27 UTC (permalink / raw)
  To: Phil Sainty; +Cc: Lars Ingebrigtsen, Robert Irelan, 46958

Phil Sainty <psainty@orcon.net.nz> writes:

> On 7/03/21 7:28 am, Robert Irelan wrote:
>> The call that's actually failing is located here:
>> https://git.sr.ht/~l3kn/org-fc/tree/711511192c62f6dccc96644dcf0705fda99e753a/item/org-fc-type-normal.el#L41.
>
> It looks like org-fc-type-normal.el should (require 'org-fc)
> at the start.
>
> Does that fix the problem?

If it does, does that make this a duplicate of bug#43717?

Thanks,

-- 
Basil





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#46958: 28.0.50; invalid-function error for macros that have function bindings
  2021-03-06 12:55 ` Lars Ingebrigtsen
  2021-03-06 14:24   ` Basil L. Contovounesios
@ 2021-03-07 14:33   ` Pip Cet
  2021-03-07 15:58     ` Lars Ingebrigtsen
  1 sibling, 1 reply; 14+ messages in thread
From: Pip Cet @ 2021-03-07 14:33 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Robert Irelan, 46958

On Sat, Mar 6, 2021 at 12:56 PM Lars Ingebrigtsen <larsi@gnus.org> wrote:
> The other issue is that I think there's a misunderstanding here: You can
> never funcall a macro.

You shouldn't be able to, but I don't think bug#46636 has been fixed.

Pip





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#46958: 28.0.50; invalid-function error for macros that have function bindings
  2021-03-07 14:33   ` Pip Cet
@ 2021-03-07 15:58     ` Lars Ingebrigtsen
  2021-03-07 18:06       ` Pip Cet
  0 siblings, 1 reply; 14+ messages in thread
From: Lars Ingebrigtsen @ 2021-03-07 15:58 UTC (permalink / raw)
  To: Pip Cet; +Cc: Robert Irelan, 46958

Pip Cet <pipcet@gmail.com> writes:

> On Sat, Mar 6, 2021 at 12:56 PM Lars Ingebrigtsen <larsi@gnus.org> wrote:
>> The other issue is that I think there's a misunderstanding here: You can
>> never funcall a macro.
>
> You shouldn't be able to, but I don't think bug#46636 has been fixed.

That's not a bug about funcalling macros, but about M-: using
`macroexpand-all' before evaluating, isn't it?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#46958: 28.0.50; invalid-function error for macros that have function bindings
  2021-03-07 15:58     ` Lars Ingebrigtsen
@ 2021-03-07 18:06       ` Pip Cet
  0 siblings, 0 replies; 14+ messages in thread
From: Pip Cet @ 2021-03-07 18:06 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Robert Irelan, 46958

On Sun, Mar 7, 2021 at 3:58 PM Lars Ingebrigtsen <larsi@gnus.org> wrote:
> Pip Cet <pipcet@gmail.com> writes:
> > On Sat, Mar 6, 2021 at 12:56 PM Lars Ingebrigtsen <larsi@gnus.org> wrote:
> >> The other issue is that I think there's a misunderstanding here: You can
> >> never funcall a macro.
> >
> > You shouldn't be able to, but I don't think bug#46636 has been fixed.
>
> That's not a bug about funcalling macros,

Funny, that's precisely what it sounds like to me.

> but about M-: using
> `macroexpand-all' before evaluating, isn't it?

That's where the bug is, yes, but together with the analogous byte
optimizer bug it means that all of the usual ways of evaluating
(funcall #'when t) will succeed. That means you can funcall macros, in
my book.

Pip





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#46958: 28.0.50; invalid-function error for macros that have function bindings
  2021-03-06 22:39       ` Phil Sainty
  2021-03-07 14:27         ` Basil L. Contovounesios
@ 2021-03-07 21:38         ` Robert Irelan
  2021-03-08  6:30           ` Phil Sainty
  1 sibling, 1 reply; 14+ messages in thread
From: Robert Irelan @ 2021-03-07 21:38 UTC (permalink / raw)
  To: Phil Sainty; +Cc: Basil L. Contovounesios, Lars Ingebrigtsen, 46958

No, that results in a circular import.

The way this file (not my code, by the way) seems to work is that it
started out as one file, org-fc.el, that contained everything. At
various points, they decided to break out some parts of the file into
separate files like this:

```
;;; org-fc.el

;; ... some definitions, including macro
`org-fc-with-point-at-back-heading' and the other `org-fc' symbols
mentioned in org-fc-type-normal.el

(require 'org-fc-type-normal)

;; ... some more definitions

(provide 'org-fc)
```

```
;;; org-fc-type-normal.el

(defun org-fc-type-normal-init ()
  "Mark headline as card of the normal type."
  (interactive)
  (org-fc--init-card "normal")
  (org-fc-review-data-update '("front")))

(defun org-fc-type-normal-setup (_position)
  "Prepare a normal card for review."
  (interactive)
  ;; Make sure the card is collapsed
  (outline-hide-subtree)
  (when (org-fc-has-back-heading-p)
    (org-show-entry)
    ;; Make sure the back heading is visible
    (org-fc-with-point-at-back-heading
     (org-show-set-visibility 'minimal))))

(defun org-fc-type-normal-flip ()
  "Flip a normal card."
  (interactive)
  (org-show-entry)
  (org-show-children)
  ;; NOTE: the body only runs if the card has a back heading
  (org-fc-with-point-at-back-heading
   (org-show-entry)
   (org-show-children)
   (org-fc-show-latex)))

(org-fc-register-type
 'normal
 'org-fc-type-normal-setup
 'org-fc-type-normal-flip
 'org-fc-noop)

;;; Footer

(provide 'org-fc-type-normal)
```

Note that `org-fc-type-normal.el` doesn't `require` anything from
`org-fc`, but assumes that they have been already defined by the time
`org-fc.el` runs the `require` call.

On Sat, Mar 6, 2021 at 2:39 PM Phil Sainty <psainty@orcon.net.nz> wrote:
>
> On 7/03/21 7:28 am, Robert Irelan wrote:
> > The call that's actually failing is located here:
> > https://git.sr.ht/~l3kn/org-fc/tree/711511192c62f6dccc96644dcf0705fda99e753a/item/org-fc-type-normal.el#L41.
>
> It looks like org-fc-type-normal.el should (require 'org-fc)
> at the start.
>
> Does that fix the problem?
>


-- 
Robert Irelan
rirelan@gmail.com





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#46958: 28.0.50; invalid-function error for macros that have function bindings
  2021-03-07 21:38         ` Robert Irelan
@ 2021-03-08  6:30           ` Phil Sainty
  2021-03-08  7:18             ` Robert Irelan
  0 siblings, 1 reply; 14+ messages in thread
From: Phil Sainty @ 2021-03-08  6:30 UTC (permalink / raw)
  To: Robert Irelan; +Cc: Basil L. Contovounesios, Lars Ingebrigtsen, 46958

On 8/03/21 10:38 am, Robert Irelan wrote:
> No, that results in a circular import.

I think a traditional way of dealing with this is to move the
macro definitions to a separate library (e.g. fc-macs.el) and
each library which uses the macros can then (require 'fc-macs)






^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#46958: 28.0.50; invalid-function error for macros that have function bindings
  2021-03-08  6:30           ` Phil Sainty
@ 2021-03-08  7:18             ` Robert Irelan
  2021-03-08  9:06               ` Phil Sainty
  2022-06-20  1:10               ` Lars Ingebrigtsen
  0 siblings, 2 replies; 14+ messages in thread
From: Robert Irelan @ 2021-03-08  7:18 UTC (permalink / raw)
  To: Phil Sainty; +Cc: Basil L. Contovounesios, Lars Ingebrigtsen, 46958

I extracted the macros into a separate library `org-fc-macs` and then
called `(require 'org-fc-macs)` from the file where the error is
occurring `org-fc-type-normal.el`. This seems to have fixed the issue.

Now that I see that this has resolved the issue, I believe I can
understand why. It looks the byte compiler can deal well if it is
compiling a file where a function isn't defined by any of the
`require` calls in the file - as long as the function is defined at
runtime (which it would be with the way `org-fc` is written), you
won't run into any issues. On the other hand, the byte compiler needs
to have the definitions of all macros at hand during compile time, or
else it won't be able to expand them correctly:
https://www.gnu.org/software/emacs/manual/html_node/elisp/Compiling-Macros.html.

In my case I'm using Doom Emacs, which uses the Straight package
manager. Straight has switched to byte compiling each package (along
with its explicit dependencies) in a separate process recently. When
this happened, `org-fc-type-normal.el` could no longer see the macro
definitions from `org-fc.el` at compile time, even though it could see
them at run time. Here's an explanation from the Doom Emacs package
maintainer: https://github.com/hlissner/doom-emacs/issues/4539#issuecomment-766307714.

Therefore, it looks like this is not a new bug in Emacs. It would be
nice if, when an invalid-function is thrown from bytecode, to check
the runtime environment to see a macro with the same name is defined,
and print a more informative error pointing out an issue with the
compilation.

On Sun, Mar 7, 2021 at 10:30 PM Phil Sainty <psainty@orcon.net.nz> wrote:
>
> On 8/03/21 10:38 am, Robert Irelan wrote:
> > No, that results in a circular import.
>
> I think a traditional way of dealing with this is to move the
> macro definitions to a separate library (e.g. fc-macs.el) and
> each library which uses the macros can then (require 'fc-macs)
>


-- 
Robert Irelan
rirelan@gmail.com





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#46958: 28.0.50; invalid-function error for macros that have function bindings
  2021-03-08  7:18             ` Robert Irelan
@ 2021-03-08  9:06               ` Phil Sainty
  2022-06-20  1:10               ` Lars Ingebrigtsen
  1 sibling, 0 replies; 14+ messages in thread
From: Phil Sainty @ 2021-03-08  9:06 UTC (permalink / raw)
  To: Robert Irelan; +Cc: Basil L. Contovounesios, Lars Ingebrigtsen, 46958

On 8/03/21 8:18 pm, Robert Irelan wrote:
> I extracted the macros into a separate library `org-fc-macs` and then
> called `(require 'org-fc-macs)` from the file where the error is
> occurring `org-fc-type-normal.el`. This seems to have fixed the issue.

Good to hear.

I'll just add that my suggestion wasn't quite optimal -- as this is
a macros-only library, a better way to require it is:

(eval-when-compile (require 'org-fc-macs))

This ensures that macros are loaded for byte-compilation, but means
that subsequently loading the byte-compiled .elc library does *not*
load org-fc-macs (which is not needed in this scenario as, in the
byte-compiled code, the macro calls have already been expanded).


-Phil





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#46958: 28.0.50; invalid-function error for macros that have function bindings
  2021-03-08  7:18             ` Robert Irelan
  2021-03-08  9:06               ` Phil Sainty
@ 2022-06-20  1:10               ` Lars Ingebrigtsen
  1 sibling, 0 replies; 14+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-20  1:10 UTC (permalink / raw)
  To: Robert Irelan; +Cc: Phil Sainty, Basil L. Contovounesios, 46958

Robert Irelan <rirelan@gmail.com> writes:

> Therefore, it looks like this is not a new bug in Emacs. It would be
> nice if, when an invalid-function is thrown from bytecode, to check
> the runtime environment to see a macro with the same name is defined,
> and print a more informative error pointing out an issue with the
> compilation.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

I'm not sure there's much to be done here on the Emacs side.  When you
compiled the file, you should have gotten a byte compilation warning
about the macro not being defined.  The runtime error (about funcalling
the macro) could be expanded, of course, to something like "invalid
function (probably a missing byte compilation `require')" or something,
but I don't think that'd add a lot of value -- since you only get into
this situation by ignoring the byte compiler warning in the first case.

So I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-06-20  1:10 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-06  2:00 bug#46958: 28.0.50; invalid-function error for macros that have function bindings Robert Irelan
2021-03-06 12:55 ` Lars Ingebrigtsen
2021-03-06 14:24   ` Basil L. Contovounesios
2021-03-06 18:28     ` Robert Irelan
2021-03-06 22:39       ` Phil Sainty
2021-03-07 14:27         ` Basil L. Contovounesios
2021-03-07 21:38         ` Robert Irelan
2021-03-08  6:30           ` Phil Sainty
2021-03-08  7:18             ` Robert Irelan
2021-03-08  9:06               ` Phil Sainty
2022-06-20  1:10               ` Lars Ingebrigtsen
2021-03-07 14:33   ` Pip Cet
2021-03-07 15:58     ` Lars Ingebrigtsen
2021-03-07 18:06       ` Pip Cet

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).