diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2021-01-21 13:15:05 -0500 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2021-01-21 13:15:05 -0500 |
commit | b41b4add7bc2485fadc6ff3a890efbd1307b2351 (patch) | |
tree | c9a07528185cd511820635a04abbfbd0329218e3 /test/lisp/emacs-lisp/bytecomp-resources | |
parent | 931be5ee7d618904361ab2d434d3901cbd9abc9a (diff) | |
download | emacs-b41b4add7bc2485fadc6ff3a890efbd1307b2351.tar.gz emacs-b41b4add7bc2485fadc6ff3a890efbd1307b2351.tar.bz2 emacs-b41b4add7bc2485fadc6ff3a890efbd1307b2351.zip |
Fix spurious "Lexical argument shadows the dynamic variable" due to inlining
Before this patch doing:
rm lisp/calendar/calendar.elc
make lisp/calendar/cal-hebrew.elc
would spew out lots of spurious such warnings about a `date` argument,
pointing to code which has no `date` argument in sight. This was
because that code had calls to inlinable functions (taking a `date`
argument) defined in `calendar.el`, and while `date` is a normal
lexical var at the site of those functions' definitions, it was
declared as dynbound at the call site.
* lisp/emacs-lisp/byte-opt.el (byte-compile-inline-expand):
Don't impose our local context onto the inlined function.
* test/lisp/emacs-lisp/bytecomp-tests.el: Add matching test.
Diffstat (limited to 'test/lisp/emacs-lisp/bytecomp-resources')
-rw-r--r-- | test/lisp/emacs-lisp/bytecomp-resources/foo-inlinable.el | 6 | ||||
-rw-r--r-- | test/lisp/emacs-lisp/bytecomp-resources/nowarn-inline-after-defvar.el | 17 |
2 files changed, 23 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/bytecomp-resources/foo-inlinable.el b/test/lisp/emacs-lisp/bytecomp-resources/foo-inlinable.el new file mode 100644 index 00000000000..47481574ea8 --- /dev/null +++ b/test/lisp/emacs-lisp/bytecomp-resources/foo-inlinable.el @@ -0,0 +1,6 @@ +;; -*- lexical-binding: t; -*- + +(defsubst foo-inlineable (foo-var) + (+ foo-var 2)) + +(provide 'foo-inlinable) diff --git a/test/lisp/emacs-lisp/bytecomp-resources/nowarn-inline-after-defvar.el b/test/lisp/emacs-lisp/bytecomp-resources/nowarn-inline-after-defvar.el new file mode 100644 index 00000000000..5582b2ab0ea --- /dev/null +++ b/test/lisp/emacs-lisp/bytecomp-resources/nowarn-inline-after-defvar.el @@ -0,0 +1,17 @@ +;; -*- lexical-binding: t; -*- + +;; In this test, we try and make sure that inlined functions's code isn't +;; mistakenly re-interpreted in the caller's context: we import an +;; inlinable function from another file where `foo-var' is a normal +;; lexical variable, and then call(inline) it in a function where +;; `foo-var' is a dynamically-scoped variable. + +(require 'foo-inlinable + (expand-file-name "foo-inlinable.el" + (file-name-directory + (or byte-compile-current-file load-file-name)))) + +(defvar foo-var) + +(defun foo-fun () + (+ (foo-inlineable 5) 1)) |