GNU bug report logs - #55355
TBD: inappropriate inlining, cmacro errors

Previous Next

Package: emacs;

Reported by: Ivan Sokolov <ivan-p-sokolov <at> ya.ru>

Date: Tue, 10 May 2022 22:58:02 UTC

Severity: normal

To reply to this bug, email your comments to 55355 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#55355; Package emacs. (Tue, 10 May 2022 22:58:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ivan Sokolov <ivan-p-sokolov <at> ya.ru>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 10 May 2022 22:58:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ivan Sokolov <ivan-p-sokolov <at> ya.ru>
To: bug-gnu-emacs <at> gnu.org
Subject: TBD: inappropriate inlining, cmacro errors
Date: Wed, 11 May 2022 01:57:17 +0300
Hi all! I encountered inlining errors, unfortunately I have no idea what
is causing them.

Here is the code:

(cl-defstruct (foo (:constructor foo<-list ((bar _ baz))))
  bar
  baz)

(foo<-list '(1 2 3))                    ; does not work

(funcall #'foo<-list '(1 2 3))          ; does not work

(apply #'foo<-list '(1 2 3) nil)        ; does work

Here is the backtrace:

Debugger entered--Lisp error: (wrong-number-of-arguments foo<-list--cmacro 2)
  signal(wrong-number-of-arguments (foo<-list--cmacro 2))
  (if (= (length --cl-rest--) 3) (pop --cl-rest--) (signal 'wrong-number-of-arguments (list 'foo<-list--cmacro (length --cl-rest--))))
  (let* ((--cl-rest-- (if (= (length --cl-rest--) 1) (car --cl-rest--) (signal 'wrong-number-of-arguments (list 'foo<-list--cmacro (length --cl-rest--))))) (bar (if (= (length --cl-rest--) 3) (pop --cl-rest--) (signal 'wrong-number-of-arguments (list 'foo<-list--cmacro (length --cl-rest--))))) (_ (pop --cl-rest--)) (baz (car --cl-rest--))) (cl-block foo<-list--cmacro (cl--defsubst-expand '(bar _ baz) '(cl-block foo<-list (record 'foo bar baz)) nil nil nil bar _ baz)))
  foo<-list--cmacro((foo<-list '(1 2 3)) '(1 2 3))
  apply(foo<-list--cmacro (foo<-list '(1 2 3)) '(1 2 3))
  macroexp--compiler-macro(foo<-list--cmacro (foo<-list '(1 2 3)))
  #f(compiled-function (form func) #<bytecode -0x1ed89cfba17e95bb>)(((foo<-list '(1 2 3))) foo<-list)
  macroexp--expand-all((foo<-list '(1 2 3)))
  macroexp--all-forms((progn (foo<-list '(1 2 3))) 1)
  #f(compiled-function (form func) #<bytecode -0x1ed89cfba17e95bb>)(((progn (foo<-list '(1 2 3)))) progn)
  macroexp--expand-all((progn (foo<-list '(1 2 3))))
  macroexpand-all((progn (foo<-list '(1 2 3))))
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

Affected versions:

GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, cairo version 1.16.0)

GNU Emacs 28.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.17.6) of 2022-04-28




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55355; Package emacs. (Wed, 11 May 2022 12:11:02 GMT) Full text and rfc822 format available.

Message #8 received at 55355 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Ivan Sokolov <ivan-p-sokolov <at> ya.ru>
Cc: 55355 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#55355: TBD: inappropriate inlining, cmacro errors
Date: Wed, 11 May 2022 14:10:44 +0200
(What does "TBD" mean here?  To be decided?)

Ivan Sokolov <ivan-p-sokolov <at> ya.ru> writes:

> Hi all! I encountered inlining errors, unfortunately I have no idea what
> is causing them.
>
> Here is the code:
>
> (cl-defstruct (foo (:constructor foo<-list ((bar _ baz))))
>   bar
>   baz)
>
> (foo<-list '(1 2 3))                    ; does not work
>
> (funcall #'foo<-list '(1 2 3))          ; does not work
>
> (apply #'foo<-list '(1 2 3) nil)        ; does work
>
> Here is the backtrace:
>
> Debugger entered--Lisp error: (wrong-number-of-arguments foo<-list--cmacro 2)
>   signal(wrong-number-of-arguments (foo<-list--cmacro 2))

Perhaps Stefan has some comments; added to the CCs.

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55355; Package emacs. (Wed, 11 May 2022 18:21:02 GMT) Full text and rfc822 format available.

Message #11 received at 55355 <at> debbugs.gnu.org (full text, mbox):

From: Ivan Sokolov <ivan-p-sokolov <at> ya.ru>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 55355 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#55355: TBD: inappropriate inlining, cmacro errors
Date: Wed, 11 May 2022 18:20:41 +0000

On May 11, 2022 12:10:44 PM UTC, Lars Ingebrigtsen <larsi <at> gnus.org> wrote:
>(What does "TBD" mean here?  To be decided?)

Yeah, to be discussed or decided, I am sure there are a better name for the issue.

I asked my friends to test the code and they had even more interesting results:

(foo<-list (1 2 3)) ; works, no quote

(funcall #'foo<-list (1 2 3)) ; works, no quote

Version:
GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.30, cairo version 1.16.0)
Commit: 734f0f68a492f999a307e1cfa6f1cd7df408333f




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55355; Package emacs. (Wed, 11 May 2022 18:43:01 GMT) Full text and rfc822 format available.

Message #14 received at 55355 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ivan Sokolov <ivan-p-sokolov <at> ya.ru>
Cc: larsi <at> gnus.org, 55355 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
Subject: Re: bug#55355: TBD: inappropriate inlining, cmacro errors
Date: Wed, 11 May 2022 21:42:04 +0300
> Cc: 55355 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
> Date: Wed, 11 May 2022 18:20:41 +0000
> From: Ivan Sokolov <ivan-p-sokolov <at> ya.ru>
> 
> On May 11, 2022 12:10:44 PM UTC, Lars Ingebrigtsen <larsi <at> gnus.org> wrote:
> >(What does "TBD" mean here?  To be decided?)
> 
> Yeah, to be discussed or decided, I am sure there are a better name for the issue.

To Be Determined.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55355; Package emacs. (Wed, 11 May 2022 20:23:01 GMT) Full text and rfc822 format available.

Message #17 received at 55355 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 55355 <at> debbugs.gnu.org, Ivan Sokolov <ivan-p-sokolov <at> ya.ru>
Subject: Re: bug#55355: TBD: inappropriate inlining, cmacro errors
Date: Wed, 11 May 2022 16:22:23 -0400
>> (cl-defstruct (foo (:constructor foo<-list ((bar _ baz))))
>>   bar
>>   baz)
[...]
> Perhaps Stefan has some comments; added to the CCs.

Looks like another bug in `cl-defsubst`.

To the extent that I dislike this "destructuring args" in function
signatures, I'd recommend "if it hurts, don't do that".

You can probably work around the problem using the `:noinline` feature
added recently to `cl-defstruct`.  As for a fix, it's probably a small
matter of making `cl-defsubst` give up on inlining when the formal
arglist is "too complex".


        Stefan





This bug report was last modified 3 years and 36 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.