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

[PATCH] Make symbolic references diagnostic less cryptic #12069

Closed
p5pRT opened this issue Apr 19, 2012 · 6 comments
Closed

[PATCH] Make symbolic references diagnostic less cryptic #12069

p5pRT opened this issue Apr 19, 2012 · 6 comments

Comments

@p5pRT
Copy link

p5pRT commented Apr 19, 2012

Migrated from rt.perl.org#112542 (status was 'resolved')

Searchable as RT112542$

@p5pRT
Copy link
Author

p5pRT commented Apr 19, 2012

From @Smylers

This is a bug report for perl from Smylers@​stripey.com,
generated with the help of perlbug 1.39 running under perl 5.15.9.

From 34d0e59777e8cf0638f92115e3a31a9d9be5637c Mon Sep 17 00​:00​:00 2001
From​: Smylers <Smylers@​stripey.com>
Date​: Thu, 12 Apr 2012 13​:30​:37 +0100
Subject​: [PATCH] Make symbolic references diagnostic less cryptic

If somebody has accidentally used a symbolic reference with strict enabled and
are looking for diagnostics then it's likely they didn't intend to use a
symbolic reference at all. A beginner may not even know what a symbolic
reference is, or even a reference.

So explain the error in terms of what the user has done, not what sort of
references are allowed. Provide a simple example of how this error can occur,
so even those who don't know about references have a chance of spotting and
fixing their mistake.


pod/perldiag.pod | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)

Inline Patch
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index 9a8c934..3cf0188 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -1268,8 +1268,13 @@ test the type of the reference, if need be.
 
 =item Can't use string ("%s") as %s ref while "strict refs" in use
 
-(F) Only hard references are allowed by "strict refs".  Symbolic
-references are disallowed.  See L<perlref>.
+(F) You've told Perl to dereference a string, something which C<use strict>
+blocks to prevent it happening accidentally. See
+L<perlref/"Symbolic references">. This can be triggered by an C<@> or C<$> in a
+double-quoted string immediately before interpolating a variable, for example
+in C<"user @$twitter_id">, which says to treat the contents of C<$twitter_id>
+as an array reference; use a C<\> to have a literal C<@> symbol followed by the
+contents of C<$twitter_id>: C<"user \@$twitter_id">.
 
 =item Can't use subscript on %s
 
-- 
1.7.1

Flags​:
  category=docs
  severity=low


Site configuration information for perl 5.15.9​:

Configured by smyers at Thu Apr 12 12​:48​:17 BST 2012.

Summary of my perl5 (revision 5 version 15 subversion 9) configuration​:
  Derived from​: 2653c1e
  Platform​:
  osname=linux, osvers=2.6.35-32-generic, archname=i686-linux
  uname='linux smyers-laptop 2.6.35-32-generic #67-ubuntu smp mon mar 5 19​:35​:26 utc 2012 i686 gnulinux '
  config_args='-des -Dusedevel'
  hint=recommended, useposix=true, d_sigaction=define
  useithreads=undef, usemultiplicity=undef
  useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
  use64bitint=undef, use64bitall=undef, uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
  optimize='-O2',
  cppflags='-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/lib/i686-linux-gnu /usr/lib64
  libs=-lnsl -ldl -lm -lcrypt -lutil -lc
  perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
  libc=/lib/libc-2.12.1.so, so=so, useshrplib=false, libperl=libperl.a
  gnulibc_version='2.12.1'
  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.15.9​:
  lib
  /home/smyers/lib/perl5/site_perl
  /home/smyers/lib/perl5
  /usr/local/lib/perl5/site_perl/5.15.9/i686-linux
  /usr/local/lib/perl5/site_perl/5.15.9
  /usr/local/lib/perl5/5.15.9/i686-linux
  /usr/local/lib/perl5/5.15.9
  .


Environment for perl 5.15.9​:
  HOME=/home/smyers
  LANG=en_GB.utf8
  LANGUAGE (unset)
  LC_COLLATE=C
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=/home/smyers/bin​:/usr/local/sbin​:/usr/local/bin​:/sbin​:/bin​:/usr/sbin​:/usr/bin​:/usr/X11R6/bin​:/usr/games
  PERL5LIB=/home/smyers/lib/perl5/site_perl​:/home/smyers/lib/perl5
  PERL_BADLANG (unset)
  PERL_CPANM_OPT=--sudo --prompt
  SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Apr 19, 2012

From @cpansprout

On Thu Apr 19 05​:10​:21 2012, smylers@​stripey.com wrote​:

This is a bug report for perl from Smylers@​stripey.com,
generated with the help of perlbug 1.39 running under perl 5.15.9.

From 34d0e59777e8cf0638f92115e3a31a9d9be5637c Mon Sep 17 00​:00​:00 2001
From​: Smylers <Smylers@​stripey.com>
Date​: Thu, 12 Apr 2012 13​:30​:37 +0100
Subject​: [PATCH] Make symbolic references diagnostic less cryptic

If somebody has accidentally used a symbolic reference with strict
enabled and
are looking for diagnostics then it's likely they didn't intend to use
a
symbolic reference at all. A beginner may not even know what a
symbolic
reference is, or even a reference.

So explain the error in terms of what the user has done, not what sort
of
references are allowed. Provide a simple example of how this error can
occur,
so even those who don't know about references have a chance of
spotting and
fixing their mistake.
---
pod/perldiag.pod | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index 9a8c934..3cf0188 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@​@​ -1268,8 +1268,13 @​@​ test the type of the reference, if need be.

=item Can't use string ("%s") as %s ref while "strict refs" in use

-(F) Only hard references are allowed by "strict refs". Symbolic
-references are disallowed. See L<perlref>.
+(F) You've told Perl to dereference a string, something which C<use
strict>
+blocks to prevent it happening accidentally. See
+L<perlref/"Symbolic references">. This can be triggered by an C<@​> or
C<$> in a
+double-quoted string immediately before interpolating a variable, for
example
+in C<"user @​$twitter_id">, which says to treat the contents of
C<$twitter_id>
+as an array reference; use a C<\> to have a literal C<@​> symbol
followed by the
+contents of C<$twitter_id>​: C<"user \@​$twitter_id">.

=item Can't use subscript on %s

That sounds good. We are currently in code freeze, but I hope to apply
it after the release of 5.16.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Apr 19, 2012

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

@p5pRT
Copy link
Author

p5pRT commented Apr 21, 2012

From perl-diddler@tlinx.org

Smylers (via RT) wrote​:

So explain the error in terms of what the user has done, not what sort of
references are allowed. Provide a simple example of how this error can occur,
so even those who don't know about references have a chance of spotting and
fixing their mistake.


  Anything that increases the clarity of perl error messages is, IMO,
a beautiful
thing (and my major was CS!)... $jargon="bad";

@p5pRT
Copy link
Author

p5pRT commented May 22, 2012

From @cpansprout

On Thu Apr 19 05​:10​:21 2012, smylers@​stripey.com wrote​:

This is a bug report for perl from Smylers@​stripey.com,
generated with the help of perlbug 1.39 running under perl 5.15.9.

From 34d0e59777e8cf0638f92115e3a31a9d9be5637c Mon Sep 17 00​:00​:00 2001
From​: Smylers <Smylers@​stripey.com>
Date​: Thu, 12 Apr 2012 13​:30​:37 +0100
Subject​: [PATCH] Make symbolic references diagnostic less cryptic

Thank you. Applied as 3f38d37.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented May 22, 2012

@cpansprout - Status changed from 'open' to 'resolved'

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

No branches or pull requests

1 participant