GNU bug report logs - #13605
24.3.50; Eager macro-expansion failure: (void-variable ruby-syntax-methods-before-regexp) when ruby-mode is not compiled

Previous Next

Package: emacs;

Reported by: Dmitry Gutov <dgutov <at> yandex.ru>

Date: Fri, 1 Feb 2013 21:37:02 UTC

Severity: normal

Found in version 24.3.50

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 13605 in the body.
You can then email your comments to 13605 AT debbugs.gnu.org in the normal way.

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#13605; Package emacs. (Fri, 01 Feb 2013 21:37:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Dmitry Gutov <dgutov <at> yandex.ru>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 01 Feb 2013 21:37:02 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3.50; Eager macro-expansion failure: (void-variable
	ruby-syntax-methods-before-regexp) when ruby-mode is not compiled
Date: Sat, 02 Feb 2013 01:25:57 +0400
This applies both to trunk and emacs-24.

ruby-mode compiles without warnings, and ruby-syntax-propertize-function
works fine either way, but when ruby-mode is not compiled, it shows the
subject warning upon loading, and ruby-syntax-propertize-function is an
order of magnitude slower (not very noticeable in the simple cased, though),
due to syntax-propertize-rules not being expanded.

The constant in question is defined in an `eval-and-compile' block, I
can't see what else could the interpreter need. Help?

In GNU Emacs 24.3.50.2 (x86_64-unknown-linux-gnu, GTK+ Version 3.6.0)
 of 2013-01-27 on vbx
Bzr revision: 111609 michael.albinus <at> gmx.de-20130127104333-93qmx98ovt4m0y5q
Windowing system distributor `The X.Org Foundation', version 11.0.11300000
System Description:	Ubuntu 12.10




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13605; Package emacs. (Fri, 01 Feb 2013 23:32:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 13605 <at> debbugs.gnu.org
Subject: Re: bug#13605: 24.3.50; Eager macro-expansion failure: (void-variable
	ruby-syntax-methods-before-regexp) when ruby-mode is not compiled
Date: Fri, 01 Feb 2013 18:30:31 -0500
> The constant in question is defined in an `eval-and-compile' block, I
> can't see what else could the interpreter need. Help?

Eager macro expansion works at the granularity of top-level expressions,
so the whole (if (eval-when-compile (fboundp #'syntax-propertize-rules)) ...)
block is macro-expanded before it gets run.

The patch below should work around the problem (probably best option
for emacs-24).

Maybe the better way to fix it (for trunk) is to change eval-and-compile
(and probably eval-when-compile) so that it evaluates its argument during
macro-expansion.


        Stefan


=== modified file 'lisp/progmodes/ruby-mode.el'
--- lisp/progmodes/ruby-mode.el	2013-01-28 02:07:42 +0000
+++ lisp/progmodes/ruby-mode.el	2013-02-01 23:24:39 +0000
@@ -1211,10 +1211,8 @@
 (declare-function ruby-syntax-enclosing-percent-literal "ruby-mode" (limit))
 (declare-function ruby-syntax-propertize-percent-literal "ruby-mode" (limit))
 
-(if (eval-when-compile (fboundp #'syntax-propertize-rules))
-    ;; New code that works independently from font-lock.
-    (progn
-      (eval-and-compile
+
+(eval-and-compile
         (defconst ruby-percent-literal-beg-re
           "\\(%\\)[qQrswWx]?\\([[:punct:]]\\)"
           "Regexp to match the beginning of percent literal.")
@@ -1225,6 +1223,10 @@
           "Methods that can take regexp as the first argument.
 It will be properly highlighted even when the call omits parens."))
 
+(if (eval-when-compile (fboundp #'syntax-propertize-rules))
+    ;; New code that works independently from font-lock.
+    (progn
+
       (defun ruby-syntax-propertize-function (start end)
         "Syntactic keywords for Ruby mode.  See `syntax-propertize-function'."
         (goto-char start)





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13605; Package emacs. (Sat, 02 Feb 2013 02:24:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 13605 <at> debbugs.gnu.org
Subject: Re: bug#13605: 24.3.50; Eager macro-expansion failure: (void-variable
	ruby-syntax-methods-before-regexp) when ruby-mode is not compiled
Date: Fri, 01 Feb 2013 21:22:09 -0500
> The patch below should work around the problem (probably best option
> for emacs-24).

Actually, this is sufficiently minor that it's not worth fixing for
emacs-24, I think.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13605; Package emacs. (Sat, 02 Feb 2013 10:09:01 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 13605 <at> debbugs.gnu.org
Subject: Re: bug#13605: 24.3.50; Eager macro-expansion failure: (void-variable
	ruby-syntax-methods-before-regexp) when ruby-mode is not compiled
Date: Sat, 02 Feb 2013 14:07:46 +0400
On 02.02.2013 3:30, Stefan Monnier wrote:
>> The constant in question is defined in an `eval-and-compile' block, I
>> can't see what else could the interpreter need. Help?
>
> Eager macro expansion works at the granularity of top-level expressions,
> so the whole (if (eval-when-compile (fboundp #'syntax-propertize-rules)) ...)
> block is macro-expanded before it gets run.
>
> The patch below should work around the problem (probably best option
> for emacs-24).

The patch works fine, thank you, but looks like it's not for emacs-24 
anyway.

> Maybe the better way to fix it (for trunk) is to change eval-and-compile
> (and probably eval-when-compile) so that it evaluates its argument during
> macro-expansion.

Sounds good.
Do I install the patch (after fixing indentation), or wait for the 
better fix?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13605; Package emacs. (Mon, 04 Feb 2013 03:10:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 13605 <at> debbugs.gnu.org
Subject: Re: bug#13605: 24.3.50; Eager macro-expansion failure: (void-variable
	ruby-syntax-methods-before-regexp) when ruby-mode is not compiled
Date: Sun, 03 Feb 2013 22:08:34 -0500
>> Maybe the better way to fix it (for trunk) is to change eval-and-compile
>> (and probably eval-when-compile) so that it evaluates its argument during
>> macro-expansion.
> Sounds good.
> Do I install the patch (after fixing indentation), or wait for the
> better fix?

I think we'd better aim for the better fix.


        Stefan




Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Fri, 08 Feb 2013 16:19:02 GMT) Full text and rfc822 format available.

Notification sent to Dmitry Gutov <dgutov <at> yandex.ru>:
bug acknowledged by developer. (Fri, 08 Feb 2013 16:19:02 GMT) Full text and rfc822 format available.

Message #22 received at 13605-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 13605-done <at> debbugs.gnu.org
Subject: Re: bug#13605: 24.3.50; Eager macro-expansion failure: (void-variable
	ruby-syntax-methods-before-regexp) when ruby-mode is not compiled
Date: Fri, 08 Feb 2013 11:18:42 -0500
>>> Maybe the better way to fix it (for trunk) is to change eval-and-compile
>>> (and probably eval-when-compile) so that it evaluates its argument during
>>> macro-expansion.

I've installed the patch below which fixes this problem and hopefully
won't introduce others.


        Stefan


=== modified file 'lisp/emacs-lisp/byte-run.el'
--- lisp/emacs-lisp/byte-run.el	2013-01-03 02:37:57 +0000
+++ lisp/emacs-lisp/byte-run.el	2013-02-08 16:13:13 +0000
@@ -392,15 +392,15 @@
 Thus, the result of the body appears to the compiler as a quoted constant.
 In interpreted code, this is entirely equivalent to `progn'."
   (declare (debug t) (indent 0))
-  ;; Not necessary because we have it in b-c-initial-macro-environment
-  ;; (list 'quote (eval (cons 'progn body)))
-  (cons 'progn body))
+  (list 'quote (eval (cons 'progn body) lexical-binding)))
 
 (defmacro eval-and-compile (&rest body)
   "Like `progn', but evaluates the body at compile time and at load time."
   (declare (debug t) (indent 0))
-  ;; Remember, it's magic.
-  (cons 'progn body))
+  ;; When the byte-compiler expands code, this macro is not used, so we're
+  ;; either about to run `body' (plain interpretation) or we're doing eager
+  ;; macroexpansion.
+  (list 'quote (eval (cons 'progn body) lexical-binding)))
 
 (put 'with-no-warnings 'lisp-indent-function 0)
 (defun with-no-warnings (&rest body)





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13605; Package emacs. (Fri, 08 Feb 2013 19:16:01 GMT) Full text and rfc822 format available.

Message #25 received at 13605-done <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 13605-done <at> debbugs.gnu.org
Subject: Re: bug#13605: 24.3.50; Eager macro-expansion failure: (void-variable
	ruby-syntax-methods-before-regexp) when ruby-mode is not compiled
Date: Fri, 08 Feb 2013 23:15:20 +0400
On 08.02.2013 20:18, Stefan Monnier wrote:
>>>> Maybe the better way to fix it (for trunk) is to change eval-and-compile
>>>> (and probably eval-when-compile) so that it evaluates its argument during
>>>> macro-expansion.
>
> I've installed the patch below which fixes this problem and hopefully
> won't introduce others.

Thanks!




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 09 Mar 2013 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 108 days ago.

Previous Next


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