GNU bug report logs - #36664
27.0.50; definition of string-trim causes warning

Previous Next

Package: emacs;

Reported by: Andreas Röhler <andreas.roehler <at> easy-emacs.de>

Date: Mon, 15 Jul 2019 12:19:01 UTC

Severity: wishlist

Tags: notabug, wontfix

Found in version 27.0.50

Done: Glenn Morris <rgm <at> gnu.org>

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 36664 in the body.
You can then email your comments to 36664 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#36664; Package emacs. (Mon, 15 Jul 2019 12:19:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Andreas Röhler <andreas.roehler <at> easy-emacs.de>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 15 Jul 2019 12:19:02 GMT) Full text and rfc822 format available.

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

From: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.0.50; definition of string-trim causes warning
Date: Mon, 15 Jul 2019 14:20:11 +0200
Hi,

concerns subr-x.el

When byte-compiling a file with def of trim-string inside, get a 
warning: Lexical argument shadows the dynamic variable
    string

Changing the argument from "string" into "strg" for example should 
silence that.

Thanks,

Andreas

In GNU Emacs 27.0.50 (build 1, i686-pc-linux-gnu, GTK+ Version 3.14.5)
 of 2019-06-04







Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#36664; Package emacs. (Mon, 15 Jul 2019 12:25:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
Cc: 36664 <at> debbugs.gnu.org
Subject: Re: bug#36664: 27.0.50; definition of string-trim causes warning
Date: Mon, 15 Jul 2019 14:24:12 +0200
Andreas Röhler <andreas.roehler <at> easy-emacs.de> writes:

> concerns subr-x.el
>
> When byte-compiling a file with def of trim-string inside, get a
> warning: Lexical argument shadows the dynamic variable
>     string

I'm not sure I follow.  Do you mean if you have a function that calls
string-trim (not define trim-string?) in a file, and you compile that
file, you get that warning?

If that's what you mean, I'm unable to reproduce the error.

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#36664; Package emacs. (Mon, 15 Jul 2019 14:23:01 GMT) Full text and rfc822 format available.

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

From: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 36664 <at> debbugs.gnu.org
Subject: Re: bug#36664: 27.0.50; definition of string-trim causes warning
Date: Mon, 15 Jul 2019 16:24:50 +0200
On 15.07.19 14:24, Lars Ingebrigtsen wrote:
> Andreas Röhler <andreas.roehler <at> easy-emacs.de> writes:
>
>> concerns subr-x.el
>>
>> When byte-compiling a file with def of trim-string inside, get a
>> warning: Lexical argument shadows the dynamic variable
>>      string
> I'm not sure I follow.  Do you mean if you have a function that calls
> string-trim (not define trim-string?) in a file, and you compile that
> file, you get that warning?
>
> If that's what you mean, I'm unable to reproduce the error.
>

Have that in python-mode.el --as older Emacsen might miss the function--:

;; subr-x.el might not exist yet
(unless (functionp 'string-trim)
  (defsubst string-trim (string &optional trim-left trim-right)
    "Trim STRING of leading and trailing strings matching TRIM-LEFT and 
TRIM-RIGHT.

TRIM-LEFT and TRIM-RIGHT default to \"[ \\t\\n\\r]+\"."
    (string-trim-left (string-trim-right string trim-right) trim-left))

[...]





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#36664; Package emacs. (Mon, 15 Jul 2019 14:32:02 GMT) Full text and rfc822 format available.

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

From: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#36664: 27.0.50; definition of string-trim causes warning
Date: Mon, 15 Jul 2019 16:33:05 +0200
[Message part 1 (text/plain, inline)]
On 15.07.19 16:24, Andreas Röhler wrote:
>
> On 15.07.19 14:24, Lars Ingebrigtsen wrote:
>> Andreas Röhler <andreas.roehler <at> easy-emacs.de> writes:
>>
>>> concerns subr-x.el
>>>
>>> When byte-compiling a file with def of trim-string inside, get a
>>> warning: Lexical argument shadows the dynamic variable
>>>      string
>> I'm not sure I follow.  Do you mean if you have a function that calls
>> string-trim (not define trim-string?) in a file, and you compile that
>> file, you get that warning?
>>
>> If that's what you mean, I'm unable to reproduce the error.
>>
>
> Have that in python-mode.el --as older Emacsen might miss the function--:
>
> ;; subr-x.el might not exist yet
> (unless (functionp 'string-trim)
>   (defsubst string-trim (string &optional trim-left trim-right)
>     "Trim STRING of leading and trailing strings matching TRIM-LEFT 
> and TRIM-RIGHT.
>
> TRIM-LEFT and TRIM-RIGHT default to \"[ \\t\\n\\r]+\"."
>     (string-trim-left (string-trim-right string trim-right) trim-left))
>
> [...]
>
>

Hmm, also can't reproduce with emacs -Q, only from my config - see 
attachment.

Beside of this IMO the warning is reasonable - commonly used symbols 
should not appear as plain argument names.


>
>
[warning.png (image/png, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#36664; Package emacs. (Mon, 15 Jul 2019 15:17:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
Cc: 36664 <at> debbugs.gnu.org
Subject: Re: bug#36664: 27.0.50; definition of string-trim causes warning
Date: Mon, 15 Jul 2019 17:16:44 +0200
Andreas Röhler <andreas.roehler <at> easy-emacs.de> writes:

> Have that in python-mode.el --as older Emacsen might miss the function--:
>
> ;; subr-x.el might not exist yet
> (unless (functionp 'string-trim)
>   (defsubst string-trim (string &optional trim-left trim-right)
>     "Trim STRING of leading and trailing strings matching TRIM-LEFT
> and TRIM-RIGHT.
>
> TRIM-LEFT and TRIM-RIGHT default to \"[ \\t\\n\\r]+\"."
>     (string-trim-left (string-trim-right string trim-right) trim-left))

I put the following in /tmp/a.el and said `M-x byte-compile-file', and I
got no warning...

(unless (functionp 'string-trim)
 (defsubst string-trim (string &optional trim-left trim-right)
   "Trim STRING of leading and trailing strings matching TRIM-LEFT
and TRIM-RIGHT.

TRIM-LEFT and TRIM-RIGHT default to \"[ \\t\\n\\r]+\"."
   (string-trim-left (string-trim-right string trim-right) trim-left)))

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#36664; Package emacs. (Mon, 15 Jul 2019 15:19:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
Cc: 36664 <at> debbugs.gnu.org
Subject: Re: bug#36664: 27.0.50; definition of string-trim causes warning
Date: Mon, 15 Jul 2019 17:18:40 +0200
Well, I got the warning about the other two functions, but that's
natural:


Compiling file /tmp/a.el at Mon Jul 15 17:18:07 2019

In end of data:
a.el:12:1:Warning: the following functions are not known to be defined:
    string-trim-left, string-trim-right


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





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#36664; Package emacs. (Mon, 15 Jul 2019 15:27:03 GMT) Full text and rfc822 format available.

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

From: Noam Postavsky <npostavs <at> gmail.com>
To: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
Cc: 36664 <at> debbugs.gnu.org
Subject: Re: bug#36664: 27.0.50; definition of string-trim causes warning
Date: Mon, 15 Jul 2019 11:26:29 -0400
Andreas Röhler <andreas.roehler <at> easy-emacs.de> writes:

>>>> When byte-compiling a file with def of trim-string inside, get a
>>>> warning: Lexical argument shadows the dynamic variable
>>>>      string

> Hmm, also can't reproduce with emacs -Q, only from my config - see
> attachment.
>
> Beside of this IMO the warning is reasonable - commonly used symbols
> should not appear as plain argument names.

I think the bug is somewhere in your config, there is something like

    (defvar string "foo")

Which makes 'string' into a global special variable.





Added tag(s) notabug and wontfix. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Tue, 17 Sep 2019 01:32:01 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 36664 <at> debbugs.gnu.org and Andreas Röhler <andreas.roehler <at> easy-emacs.de> Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Tue, 17 Sep 2019 01:32:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 15 Oct 2019 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 187 days ago.

Previous Next


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