Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unused punctuation variables don't interpolate #12213

Closed
p5pRT opened this issue Jun 22, 2012 · 16 comments
Closed

Unused punctuation variables don't interpolate #12213

p5pRT opened this issue Jun 22, 2012 · 16 comments

Comments

@p5pRT
Copy link

p5pRT commented Jun 22, 2012

Migrated from rt.perl.org#113792 (status was 'rejected')

Searchable as RT113792$

@p5pRT
Copy link
Author

p5pRT commented Jun 22, 2012

From @ikegami

Created by @ikegami

$ perl -E'"abc" =~ /(b)/; say "@​+"'
2 2

$ perl -E'@​_ = qw( a b c ); say "@​_"'
a b c

$ perl -E'@​. = qw( a b c ); say "@​."'
@​.

$ perl -E'@​. = qw( a b c ); say "@​{.}"'
a b c

What's up with #3?

- Eric

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl 5.16.0:

Configured by eric at Tue May 22 01:57:47 EDT 2012.

Summary of my perl5 (revision 5 version 16 subversion 0) configuration:

  Platform:
    osname=linux, osvers=2.6.32-5-amd64, archname=x86_64-linux-thread-multi
    uname='linux eric 2.6.32-5-amd64 #1 smp mon mar 26 07:00:19 utc 2012
x86_64 gnulinux '
    config_args='-de -Dprefix=/home/eric/usr/perlbrew/perls/5.16.0t
-DPERL_SUB_DEPTH_WARN=1000 -Dusethreads'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing
-pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe
-fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.4.5', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /lib/../lib /usr/lib/../lib /lib /usr/lib
/usr/lib64
    libs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=/lib/libc-2.11.3.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.11.3'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib
-fstack-protector'

Locally applied patches:



@INC for perl 5.16.0:

/home/eric/usr/perlbrew/perls/5.16.0t/lib/site_perl/5.16.0/x86_64-linux-thread-multi
    /home/eric/usr/perlbrew/perls/5.16.0t/lib/site_perl/5.16.0

/home/eric/usr/perlbrew/perls/5.16.0t/lib/5.16.0/x86_64-linux-thread-multi
    /home/eric/usr/perlbrew/perls/5.16.0t/lib/5.16.0
    .


Environment for perl 5.16.0:
    HOME=/home/eric
    LANG=en_CA.UTF-8
    LANGUAGE=en_CA:en
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)

PATH=/home/eric/usr/perlbrew/bin:/home/eric/usr/perlbrew/perls/5.16.0t/bin:.:/home/eric/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
    PERLBREW_BASHRC_VERSION=0.42
    PERLBREW_HOME=/home/eric/.perlbrew
    PERLBREW_MANPATH=/home/eric/usr/perlbrew/perls/5.16.0t/man

PERLBREW_PATH=/home/eric/usr/perlbrew/bin:/home/eric/usr/perlbrew/perls/5.16.0t/bin
    PERLBREW_PERL=5.16.0t
    PERLBREW_ROOT=/home/eric/usr/perlbrew
    PERLBREW_VERSION=0.42
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Jun 22, 2012

From @cpansprout

On Fri Jun 22 12​:57​:15 2012, ikegami@​adaelis.com wrote​:

$ perl -E'"abc" =~ /(b)/; say "@​+"'
2 2

$ perl -E'@​_ = qw( a b c ); say "@​_"'
a b c

$ perl -E'@​. = qw( a b c ); say "@​."'
@​.

$ perl -E'@​. = qw( a b c ); say "@​{.}"'
a b c

What's up with #3?

toke.c special-cases certain punct vars. Without thinking about this in
detail, my gut feeling is that allowing "@​." will open up a can of worms.

Also, there may be people wholly unintentionally relying on this. I
know many times I’ve forgotten to escape my @​’s and wondered why they
were disappearing.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Jun 22, 2012

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jun 22, 2012

From @ikegami

On Fri, Jun 22, 2012 at 4​:08 PM, Father Chrysostomos via RT <
perlbug-followup@​perl.org> wrote​:

Also, there may be people wholly unintentionally relying on this. I
know many times I’ve forgotten to escape my @​’s and wondered why they
were disappearing.

That's an argument for a warning, seems to me. ("Possible unintended
interpolation of reserved punctuation variable")

@p5pRT
Copy link
Author

p5pRT commented Jun 22, 2012

From @ikegami

On Fri Jun 22 13​:08​:13 2012, sprout wrote​:

On Fri Jun 22 12​:57​:15 2012, ikegami@​adaelis.com wrote​:

$ perl -E'"abc" =~ /(b)/; say "@​+"'
2 2

$ perl -E'@​_ = qw( a b c ); say "@​_"'
a b c

$ perl -E'@​. = qw( a b c ); say "@​."'
@​.

$ perl -E'@​. = qw( a b c ); say "@​{.}"'
a b c

What's up with #3?

toke.c special-cases certain punct vars. Without thinking about this in
detail, my gut feeling is that allowing "@​." will open up a can of worms.

Also, there may be people wholly unintentionally relying on this. I
know many times I’ve forgotten to escape my @​’s and wondered why they
were disappearing.

Are you saying this is a documentation bug?

@p5pRT
Copy link
Author

p5pRT commented Jun 22, 2012

From tchrist@perl.com

"Eric Brine" (via RT) <perlbug-followup@​perl.org> wrote
  on Fri, 22 Jun 2012 12​:57​:15 PDT​:

$ perl -E'"abc" =~ /(b)/; say "@​+"'
2 2

$ perl -E'@​_ = qw( a b c ); say "@​_"'
a b c

$ perl -E'@​. = qw( a b c ); say "@​."'
@​.

$ perl -E'@​. = qw( a b c ); say "@​{.}"'
a b c

What's up with #3?

What's up with *#4*? How in the world is dot a legal
name inside braces without quotes around it?

--tom

@p5pRT
Copy link
Author

p5pRT commented Jun 23, 2012

From @cpansprout

On Fri Jun 22 14​:59​:35 2012, ikegami@​adaelis.com wrote​:

On Fri Jun 22 13​:08​:13 2012, sprout wrote​:

On Fri Jun 22 12​:57​:15 2012, ikegami@​adaelis.com wrote​:

$ perl -E'"abc" =~ /(b)/; say "@​+"'
2 2

$ perl -E'@​_ = qw( a b c ); say "@​_"'
a b c

$ perl -E'@​. = qw( a b c ); say "@​."'
@​.

$ perl -E'@​. = qw( a b c ); say "@​{.}"'
a b c

What's up with #3?

toke.c special-cases certain punct vars. Without thinking about this in
detail, my gut feeling is that allowing "@​." will open up a can of
worms.

Also, there may be people wholly unintentionally relying on this. I
know many times I’ve forgotten to escape my @​’s and wondered why they
were disappearing.

Are you saying this is a documentation bug?

No, but the repercussions of that sort of change worry me. Maybe I just
need to think it through more.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Jun 23, 2012

From @ikegami

On Fri, Jun 22, 2012 at 7​:55 PM, Tom Christiansen <tchrist@​perl.com> wrote​:

$ perl -E'@​. = qw( a b c ); say "@​{.}"'

abc

What's up with *#4*? How in the world is dot a legal

name inside braces without quotes around it?

This isn't a dereference, this is Perl's interpolation delimiter.

That's why C<< "${foo}" >> is allowed with strict on.
That's why C<< "${Mod​::foo}" >> is allowed.
That's why C<< "${.}" >> is allowed.

perl -wE"use strict; my $foo=123; say qq{${foo}x}
123x
perl -wE"use strict; our $foo=123; say qq{${main​::foo}x}
123x
perl -wE"use strict; say qq{${$}x}
5884x

Whoa, it's also allowed outside of a literal!

perl -wE"use strict; my $foo=123; say ${foo}
123
perl -wE"use strict; our $foo=123; say ${main​::foo}
123
perl -wE"use strict; say ${$}
5884

@p5pRT
Copy link
Author

p5pRT commented Jul 3, 2012

From mjp-bitcard@pilcrow.madison.wi.us

On Fri Jun 22 17​:51​:37 2012, sprout wrote​:

On Fri Jun 22 14​:59​:35 2012, ikegami@​adaelis.com wrote​:

On Fri Jun 22 13​:08​:13 2012, sprout wrote​:

On Fri Jun 22 12​:57​:15 2012, ikegami@​adaelis.com wrote​:
....
Also, there may be people wholly unintentionally relying on this. I
know many times I’ve forgotten to escape my @​’s and wondered why they
were disappearing.

Are you saying this is a documentation bug?

No, but the repercussions of that sort of change worry me. Maybe I just
need to think it through more.

How about adding ``(W deprecated, ambiguous) Reserved variable %s will someday interpolate''
to 5.16.x whenever an unused punct variable plausibly should have interpolated?

If the behavior is later correcte^Wchanged so that unused, reserved variables do interpolate,
it'd be charitable to replace that with a new warning​: ``(W ambiguous) Possible unintended
interpolation of reserved variable %s''

@p5pRT
Copy link
Author

p5pRT commented Jul 3, 2012

From @cpansprout

On Tue Jul 03 11​:43​:08 2012, pilcrow wrote​:

On Fri Jun 22 17​:51​:37 2012, sprout wrote​:

On Fri Jun 22 14​:59​:35 2012, ikegami@​adaelis.com wrote​:

On Fri Jun 22 13​:08​:13 2012, sprout wrote​:

On Fri Jun 22 12​:57​:15 2012, ikegami@​adaelis.com wrote​:
....
Also, there may be people wholly unintentionally relying on
this. I
know many times I’ve forgotten to escape my @​’s and wondered why
they
were disappearing.

Are you saying this is a documentation bug?

No, but the repercussions of that sort of change worry me. Maybe I
just
need to think it through more.

How about adding ``(W deprecated, ambiguous) Reserved variable %s will
someday interpolate''
to 5.16.x whenever an unused punct variable plausibly should have
interpolated?

If the behavior is later correcte^Wchanged so that unused, reserved
variables do interpolate,
it'd be charitable to replace that with a new warning​: ``(W
ambiguous) Possible unintended
interpolation of reserved variable %s''

Neither of those possibilities makes me feel uneasy.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Jun 18, 2013

From @jkeenan

On Tue Jul 03 13​:31​:50 2012, sprout wrote​:

On Tue Jul 03 11​:43​:08 2012, pilcrow wrote​:

On Fri Jun 22 17​:51​:37 2012, sprout wrote​:

On Fri Jun 22 14​:59​:35 2012, ikegami@​adaelis.com wrote​:

On Fri Jun 22 13​:08​:13 2012, sprout wrote​:

On Fri Jun 22 12​:57​:15 2012, ikegami@​adaelis.com wrote​:
....
Also, there may be people wholly unintentionally relying on
this. I
know many times I’ve forgotten to escape my @​’s and wondered why
they
were disappearing.

Are you saying this is a documentation bug?

No, but the repercussions of that sort of change worry me. Maybe I
just
need to think it through more.

How about adding ``(W deprecated, ambiguous) Reserved variable %s will
someday interpolate''
to 5.16.x whenever an unused punct variable plausibly should have
interpolated?

If the behavior is later correcte^Wchanged so that unused, reserved
variables do interpolate,
it'd be charitable to replace that with a new warning​: ``(W
ambiguous) Possible unintended
interpolation of reserved variable %s''

Neither of those possibilities makes me feel uneasy.

ikegami, sprout​:

Do you have any recommendations (warnings? doc patches?) that can help
us bring this RT to resolution?

Thank you very much.
Jim Keenan

@p5pRT
Copy link
Author

p5pRT commented Jun 18, 2013

From @cpansprout

On Mon Jun 17 17​:50​:17 2013, jkeenan wrote​:

On Tue Jul 03 13​:31​:50 2012, sprout wrote​:

On Tue Jul 03 11​:43​:08 2012, pilcrow wrote​:

On Fri Jun 22 17​:51​:37 2012, sprout wrote​:

On Fri Jun 22 14​:59​:35 2012, ikegami@​adaelis.com wrote​:

On Fri Jun 22 13​:08​:13 2012, sprout wrote​:

On Fri Jun 22 12​:57​:15 2012, ikegami@​adaelis.com wrote​:
....
Also, there may be people wholly unintentionally relying on
this. I
know many times I’ve forgotten to escape my @​’s and wondered why
they
were disappearing.

Are you saying this is a documentation bug?

No, but the repercussions of that sort of change worry me. Maybe I
just
need to think it through more.

How about adding ``(W deprecated, ambiguous) Reserved variable %s will
someday interpolate''
to 5.16.x whenever an unused punct variable plausibly should have
interpolated?

If the behavior is later correcte^Wchanged so that unused, reserved
variables do interpolate,
it'd be charitable to replace that with a new warning​: ``(W
ambiguous) Possible unintended
interpolation of reserved variable %s''

Neither of those possibilities makes me feel uneasy.

ikegami, sprout​:

Do you have any recommendations (warnings? doc patches?) that can help
us bring this RT to resolution?

If we don’t make any change here, I don’t think we need a doc patch.

As for which warning should be added (and whether "@​." should
interpolate), I don’t know. I would be interested to hear what Ricardo
thinks.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Jun 18, 2013

From @ikegami

On Mon, Jun 17, 2013 at 8​:50 PM, James E Keenan via RT <
perlbug-followup@​perl.org> wrote​:

ikegami, sprout​:

Do you have any recommendations (warnings? doc patches?) that can help
us bring this RT to resolution?

perlop says​:

---BEGIN--
"Punctuation" arrays such as @​* are usually interpolated only if the name
is enclosed in braces @​{*}, but the arrays @​_ , @​+ , and @​- are
interpolated even without braces.
---END--

So the current behaviour is covered by the current docs, and it's surely
intentional behaviour designed to reduce errors. I'm ok with that.

For the curious, the relevant section of toke.c is​:

  /* check for embedded arrays
  (@​foo, @​​::foo, @​'foo, @​{foo}, @​$foo, @​+, @​-)
  */
  else if (*s == '@​' && s[1]) {
  if (isWORDCHAR_lazy_if(s+1,UTF))
  break;
  if (strchr("​:'{$", s[1]))
  break;
  if (!PL_lex_inpat && (s[1] == '+' || s[1] == '-'))
  break; /* in regexp, neither @​+ nor @​- are interpolated */
  }

- Eric

@p5pRT
Copy link
Author

p5pRT commented Jun 18, 2013

From @rjbs

I agree with the assessment​: this is documented, the reasoning (avoid bizarre errors) seems
sound, and there is no bug here.

--
rjbs

@p5pRT
Copy link
Author

p5pRT commented Jun 18, 2013

From [Unknown Contact. See original ticket]

I agree with the assessment​: this is documented, the reasoning (avoid bizarre errors) seems
sound, and there is no bug here.

--
rjbs

@p5pRT
Copy link
Author

p5pRT commented Jun 18, 2013

@rjbs - Status changed from 'open' to 'rejected'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant