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] Include the name of the non-lvalue sub in error message #14969

Closed
p5pRT opened this issue Oct 6, 2015 · 12 comments
Closed

[PATCH] Include the name of the non-lvalue sub in error message #14969

p5pRT opened this issue Oct 6, 2015 · 12 comments

Comments

@p5pRT
Copy link

p5pRT commented Oct 6, 2015

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

Searchable as RT126281$

@p5pRT
Copy link
Author

p5pRT commented Oct 6, 2015

From @ilmari

Created by @ilmari

This makes the cause of the error more obvious if you accidentally call
a non-lvalue sub in the final position of an lvalue one.

E.g. when adding :lvalue to the AUTOLOAD sub in Struct​::Dumb¹, it took a
while to realise that the problem was that croak() isn't lvalue².

[1] https://metacpan.org/source/PEVANS/Struct-Dumb-0.04/lib/Struct/Dumb.pm#L159
[2] https://metacpan.org/source/PEVANS/Struct-Dumb-0.05/lib/Struct/Dumb.pm#L168

Perl Info

Flags:
    category=core
    severity=low
    Type=Patch
    PatchStatus=HasPatch

Site configuration information for perl 5.23.4:

Configured by ilmari at Tue Oct  6 23:14:52 BST 2015.

Summary of my perl5 (revision 5 version 23 subversion 4) configuration:
  Commit id: 5ecffe9f2177001199e3fb4aa74f6dd35b968208
  Platform:
    osname=linux, osvers=4.1.0-1-amd64, archname=x86_64-linux
    uname='linux nurket 4.1.0-1-amd64 #1 smp debian 4.1.3-1 (2015-08-03) x86_64 gnulinux '
    config_args='-des -Dusedevel -Uversiononly'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2',
    optimize='-O2',
    cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion='', gccversion='4.9.3', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678, doublekind=3
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16, longdblkind=3
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib/gcc/x86_64-linux-gnu/4.9/include-fixed /usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib
    libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.19.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.19'
  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-strong'



@INC for perl 5.23.4:
    lib
    /home/ilmari/.perlbrew/libs/22.0@std/lib/perl5/x86_64-linux
    /home/ilmari/.perlbrew/libs/22.0@std/lib/perl5
    /usr/local/lib/perl5/site_perl/5.23.4/x86_64-linux
    /usr/local/lib/perl5/site_perl/5.23.4
    /usr/local/lib/perl5/5.23.4/x86_64-linux
    /usr/local/lib/perl5/5.23.4
    .


Environment for perl 5.23.4:
    HOME=/home/ilmari
    LANG=en_GB.utf8
    LANGUAGE=en_GB:en
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/ilmari/.perlbrew/libs/22.0@std/bin:/home/ilmari/perl5/perlbrew/bin:/home/ilmari/perl5/perlbrew/perls/22.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
    PERL5LIB=/home/ilmari/.perlbrew/libs/22.0@std/lib/perl5
    PERLBREW=command perlbrew
    PERLBREW_BASHRC_VERSION=0.73
    PERLBREW_HOME=/home/ilmari/.perlbrew
    PERLBREW_LIB=std
    PERLBREW_MANPATH=/home/ilmari/.perlbrew/libs/22.0@std/man:/home/ilmari/perl5/perlbrew/perls/22.0/man
    PERLBREW_PATH=/home/ilmari/.perlbrew/libs/22.0@std/bin:/home/ilmari/perl5/perlbrew/bin:/home/ilmari/perl5/perlbrew/perls/22.0/bin
    PERLBREW_PERL=22.0
    PERLBREW_ROOT=/home/ilmari/perl5/perlbrew
    PERLBREW_VERSION=0.73
    PERLDOC_PAGER=less -Ri
    PERL_AUTOINSTALL_PREFER_CPAN=1
    PERL_BADLANG (unset)
    PERL_LOCAL_LIB_ROOT=/home/ilmari/.perlbrew/libs/22.0@std
    PERL_MB_OPT=--install_base /home/ilmari/.perlbrew/libs/22.0@std
    PERL_MM_OPT=INSTALL_BASE=/home/ilmari/.perlbrew/libs/22.0@std
    PERL_MM_PREFER_CPAN=1
    PERL_MM_USE_DEFAULT=1
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Oct 6, 2015

From @ilmari

0001-Include-the-name-of-the-non-lvalue-sub-in-error-mess.patch
From 30e379a544579363811d8b35c4fe4b5527859188 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <ilmari@ilmari.org>
Date: Tue, 6 Oct 2015 23:13:31 +0100
Subject: [PATCH] Include the name of the non-lvalue sub in error message

This makes the cause of the error more obvious if you accidentally call
a non-lvalue sub in the final position of an lvalue one.
---
 op.c             | 10 ++++++++++
 pod/perldiag.pod |  2 +-
 pp_hot.c         |  6 ++++--
 t/op/sub_lval.t  | 16 ++++++++--------
 4 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/op.c b/op.c
index 399cf30..2d3fcd8 100644
--- a/op.c
+++ b/op.c
@@ -2792,6 +2792,7 @@ Perl_op_lvalue_flags(pTHX_ OP *o, I32 type, U32 flags)
 		OP *kid = cUNOPo->op_first;
 		CV *cv;
 		GV *gv;
+                SV *namesv;
 
 		if (kid->op_type != OP_PUSHMARK) {
 		    if (kid->op_type != OP_NULL || kid->op_targ != OP_LIST)
@@ -2829,6 +2830,15 @@ Perl_op_lvalue_flags(pTHX_ OP *o, I32 type, U32 flags)
 		    break;
 		if (CvLVALUE(cv))
 		    break;
+                if (flags & OP_LVALUE_NO_CROAK)
+                    return NULL;
+
+                namesv = cv_name(cv, NULL, 0);
+                yyerror_pv(Perl_form(aTHX_ "Can't modify non-lvalue "
+                                     "subroutine call of &%"SVf" in %s",
+                                     SVfARG(namesv), PL_op_desc[type]),
+                           SvUTF8(namesv));
+                return o;
 	    }
 	}
 	/* FALLTHROUGH */
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index db21861..d40b093 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -1108,7 +1108,7 @@ to change it, such as with an auto-increment.
 (P) The internal routine that does assignment to a substr() was handed
 a NULL.
 
-=item Can't modify non-lvalue subroutine call
+=item Can't modify non-lvalue subroutine call of &%s
 
 (F) Subroutines meant to be used in lvalue context should be declared as
 such.  See L<perlsub/"Lvalue subroutines">.
diff --git a/pp_hot.c b/pp_hot.c
index 66e8b9d..9f34ae6 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -3426,7 +3426,8 @@ PP(pp_entersub)
 	SAVETMPS;
 	if (UNLIKELY((cx->blk_u16 & OPpENTERSUB_LVAL_MASK) == OPpLVAL_INTRO &&
 	    !CvLVALUE(cv)))
-	    DIE(aTHX_ "Can't modify non-lvalue subroutine call");
+            DIE(aTHX_ "Can't modify non-lvalue subroutine call of &%"SVf,
+                SVfARG(cv_name(cv, NULL, 0)));
 	/* warning must come *after* we fully set up the context
 	 * stuff so that __WARN__ handlers can safely dounwind()
 	 * if they want to
@@ -3447,7 +3448,8 @@ PP(pp_entersub)
 	       & PUSHSUB_GET_LVALUE_MASK(Perl_is_lvalue_sub)
              ) & OPpENTERSUB_LVAL_MASK) == OPpLVAL_INTRO &&
 	    !CvLVALUE(cv)))
-	    DIE(aTHX_ "Can't modify non-lvalue subroutine call");
+            DIE(aTHX_ "Can't modify non-lvalue subroutine call of &%"SVf,
+                SVfARG(cv_name(cv, NULL, 0)));
 
 	if (UNLIKELY(!hasargs && GvAV(PL_defgv))) {
 	    /* Need to copy @_ to stack. Alternative may be to
diff --git a/t/op/sub_lval.t b/t/op/sub_lval.t
index ab9faac..f70e6fe 100644
--- a/t/op/sub_lval.t
+++ b/t/op/sub_lval.t
@@ -169,7 +169,7 @@ eval <<'EOE' or $_ = $@;
   1;
 EOE
 
-like($_, qr/Can\'t modify non-lvalue subroutine call in scalar assignment/);
+like($_, qr/Can\'t modify non-lvalue subroutine call of &main::nolv in scalar assignment/);
 
 $_ = '';
 
@@ -178,7 +178,7 @@ eval <<'EOE' or $_ = $@;
   1;
 EOE
 
-like($_, qr/Can\'t modify non-lvalue subroutine call in scalar assignment/);
+like($_, qr/Can\'t modify non-lvalue subroutine call of &main::nolv in scalar assignment/);
 
 $_ = '';
 
@@ -187,7 +187,7 @@ eval <<'EOE' or $_ = $@;
   1;
 EOE
 
-like($_, qr/Can\'t modify non-lvalue subroutine call in scalar assignment/);
+like($_, qr/Can\'t modify non-lvalue subroutine call of &main::nolv in scalar assignment/);
 
 $x0 = $x1 = $_ = undef;
 $nolv = \&nolv;
@@ -358,7 +358,7 @@ eval <<'EOE' or $_ = $@;
   1;
 EOE
 
-like($_, qr/Can\'t modify non-lvalue subroutine call at /);
+like($_, qr/Can\'t modify non-lvalue subroutine call of &main::xxx at /);
 
 $_ = undef;
 eval <<'EOE' or $_ = $@;
@@ -366,7 +366,7 @@ eval <<'EOE' or $_ = $@;
   1;
 EOE
 
-like($_, qr/Can\'t modify non-lvalue subroutine call at /);
+like($_, qr/Can\'t modify non-lvalue subroutine call of &main::xxx at /);
 
 sub yyy () { 'yyy' } # Const, not lvalue
 
@@ -823,7 +823,7 @@ foo = 3;
 ----
 lvalue attribute ignored after the subroutine has been defined at - line 4.
 lvalue attribute ignored after the subroutine has been defined at - line 6.
-Can't modify non-lvalue subroutine call in scalar assignment at - line 7, near "3;"
+Can't modify non-lvalue subroutine call of &main::foo in scalar assignment at - line 7, near "3;"
 Execution of - aborted due to compilation errors.
 ====
 }
@@ -979,7 +979,7 @@ package _102486 {
       'sub:lvalue{&$x}->() does not die for non-lvalue inner sub call';
   ::is $called, 1, 'The &$x actually called the sub';
   eval { +sub :lvalue { &$x }->() = 3 };
-  ::like $@, qr/^Can't modify non-lvalue subroutine call at /,
+  ::like $@, qr/^Can't modify non-lvalue subroutine call of &_102486::nonlv at /,
         'sub:lvalue{&$x}->() dies in true lvalue context';
 }
 
@@ -1008,7 +1008,7 @@ for (sub : lvalue { "$x" }->()) {
 
 # [perl #117947] XSUBs should not be treated as lvalues at run time
 eval { &{\&utf8::is_utf8}("") = 3 };
-like $@, qr/^Can't modify non-lvalue subroutine call at /,
+like $@, qr/^Can't modify non-lvalue subroutine call of &utf8::is_utf8 at /,
         'XSUB not seen at compile time dies in lvalue context';
 
 # [perl #119797] else implicitly returning value
-- 
2.5.1

@p5pRT
Copy link
Author

p5pRT commented Oct 6, 2015

From @ilmari

Dagfinn Ilmari Mannsåker (via RT) <perlbug-followup@​perl.org> writes​:

This makes the cause of the error more obvious if you accidentally call
a non-lvalue sub in the final position of an lvalue one.

Here's an updated patch which also removes the now-redundant OP_ENTERSUB
case in the default block of the switch.

@p5pRT
Copy link
Author

p5pRT commented Oct 6, 2015

From @ilmari

0001-Include-the-name-of-the-non-lvalue-sub-in-error-mess.patch
From 2c727a4896e53e09b4c5ac00b386833b157bd55d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <ilmari@ilmari.org>
Date: Tue, 6 Oct 2015 23:13:31 +0100
Subject: [PATCH] Include the name of the non-lvalue sub in error message

This makes the cause of the error more obvious if you accidentally call
a non-lvalue sub in the final position of an lvalue one.
---
 op.c             | 14 +++++++++++---
 pod/perldiag.pod |  2 +-
 pp_hot.c         |  6 ++++--
 t/op/sub_lval.t  | 16 ++++++++--------
 4 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/op.c b/op.c
index 399cf30..c0c321b 100644
--- a/op.c
+++ b/op.c
@@ -2792,6 +2792,7 @@ Perl_op_lvalue_flags(pTHX_ OP *o, I32 type, U32 flags)
 		OP *kid = cUNOPo->op_first;
 		CV *cv;
 		GV *gv;
+                SV *namesv;
 
 		if (kid->op_type != OP_PUSHMARK) {
 		    if (kid->op_type != OP_NULL || kid->op_targ != OP_LIST)
@@ -2829,6 +2830,15 @@ Perl_op_lvalue_flags(pTHX_ OP *o, I32 type, U32 flags)
 		    break;
 		if (CvLVALUE(cv))
 		    break;
+                if (flags & OP_LVALUE_NO_CROAK)
+                    return NULL;
+
+                namesv = cv_name(cv, NULL, 0);
+                yyerror_pv(Perl_form(aTHX_ "Can't modify non-lvalue "
+                                     "subroutine call of &%"SVf" in %s",
+                                     SVfARG(namesv), PL_op_desc[type]),
+                           SvUTF8(namesv));
+                return o;
 	    }
 	}
 	/* FALLTHROUGH */
@@ -2842,9 +2852,7 @@ Perl_op_lvalue_flags(pTHX_ OP *o, I32 type, U32 flags)
 	yyerror(Perl_form(aTHX_ "Can't modify %s in %s",
 		     (o->op_type == OP_NULL && (o->op_flags & OPf_SPECIAL)
 		      ? "do block"
-		      : (o->op_type == OP_ENTERSUB
-			? "non-lvalue subroutine call"
-			: OP_DESC(o))),
+		      : OP_DESC(o)),
 		     type ? PL_op_desc[type] : "local"));
 	return o;
 
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index db21861..d40b093 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -1108,7 +1108,7 @@ to change it, such as with an auto-increment.
 (P) The internal routine that does assignment to a substr() was handed
 a NULL.
 
-=item Can't modify non-lvalue subroutine call
+=item Can't modify non-lvalue subroutine call of &%s
 
 (F) Subroutines meant to be used in lvalue context should be declared as
 such.  See L<perlsub/"Lvalue subroutines">.
diff --git a/pp_hot.c b/pp_hot.c
index 66e8b9d..9f34ae6 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -3426,7 +3426,8 @@ PP(pp_entersub)
 	SAVETMPS;
 	if (UNLIKELY((cx->blk_u16 & OPpENTERSUB_LVAL_MASK) == OPpLVAL_INTRO &&
 	    !CvLVALUE(cv)))
-	    DIE(aTHX_ "Can't modify non-lvalue subroutine call");
+            DIE(aTHX_ "Can't modify non-lvalue subroutine call of &%"SVf,
+                SVfARG(cv_name(cv, NULL, 0)));
 	/* warning must come *after* we fully set up the context
 	 * stuff so that __WARN__ handlers can safely dounwind()
 	 * if they want to
@@ -3447,7 +3448,8 @@ PP(pp_entersub)
 	       & PUSHSUB_GET_LVALUE_MASK(Perl_is_lvalue_sub)
              ) & OPpENTERSUB_LVAL_MASK) == OPpLVAL_INTRO &&
 	    !CvLVALUE(cv)))
-	    DIE(aTHX_ "Can't modify non-lvalue subroutine call");
+            DIE(aTHX_ "Can't modify non-lvalue subroutine call of &%"SVf,
+                SVfARG(cv_name(cv, NULL, 0)));
 
 	if (UNLIKELY(!hasargs && GvAV(PL_defgv))) {
 	    /* Need to copy @_ to stack. Alternative may be to
diff --git a/t/op/sub_lval.t b/t/op/sub_lval.t
index ab9faac..f70e6fe 100644
--- a/t/op/sub_lval.t
+++ b/t/op/sub_lval.t
@@ -169,7 +169,7 @@ eval <<'EOE' or $_ = $@;
   1;
 EOE
 
-like($_, qr/Can\'t modify non-lvalue subroutine call in scalar assignment/);
+like($_, qr/Can\'t modify non-lvalue subroutine call of &main::nolv in scalar assignment/);
 
 $_ = '';
 
@@ -178,7 +178,7 @@ eval <<'EOE' or $_ = $@;
   1;
 EOE
 
-like($_, qr/Can\'t modify non-lvalue subroutine call in scalar assignment/);
+like($_, qr/Can\'t modify non-lvalue subroutine call of &main::nolv in scalar assignment/);
 
 $_ = '';
 
@@ -187,7 +187,7 @@ eval <<'EOE' or $_ = $@;
   1;
 EOE
 
-like($_, qr/Can\'t modify non-lvalue subroutine call in scalar assignment/);
+like($_, qr/Can\'t modify non-lvalue subroutine call of &main::nolv in scalar assignment/);
 
 $x0 = $x1 = $_ = undef;
 $nolv = \&nolv;
@@ -358,7 +358,7 @@ eval <<'EOE' or $_ = $@;
   1;
 EOE
 
-like($_, qr/Can\'t modify non-lvalue subroutine call at /);
+like($_, qr/Can\'t modify non-lvalue subroutine call of &main::xxx at /);
 
 $_ = undef;
 eval <<'EOE' or $_ = $@;
@@ -366,7 +366,7 @@ eval <<'EOE' or $_ = $@;
   1;
 EOE
 
-like($_, qr/Can\'t modify non-lvalue subroutine call at /);
+like($_, qr/Can\'t modify non-lvalue subroutine call of &main::xxx at /);
 
 sub yyy () { 'yyy' } # Const, not lvalue
 
@@ -823,7 +823,7 @@ foo = 3;
 ----
 lvalue attribute ignored after the subroutine has been defined at - line 4.
 lvalue attribute ignored after the subroutine has been defined at - line 6.
-Can't modify non-lvalue subroutine call in scalar assignment at - line 7, near "3;"
+Can't modify non-lvalue subroutine call of &main::foo in scalar assignment at - line 7, near "3;"
 Execution of - aborted due to compilation errors.
 ====
 }
@@ -979,7 +979,7 @@ package _102486 {
       'sub:lvalue{&$x}->() does not die for non-lvalue inner sub call';
   ::is $called, 1, 'The &$x actually called the sub';
   eval { +sub :lvalue { &$x }->() = 3 };
-  ::like $@, qr/^Can't modify non-lvalue subroutine call at /,
+  ::like $@, qr/^Can't modify non-lvalue subroutine call of &_102486::nonlv at /,
         'sub:lvalue{&$x}->() dies in true lvalue context';
 }
 
@@ -1008,7 +1008,7 @@ for (sub : lvalue { "$x" }->()) {
 
 # [perl #117947] XSUBs should not be treated as lvalues at run time
 eval { &{\&utf8::is_utf8}("") = 3 };
-like $@, qr/^Can't modify non-lvalue subroutine call at /,
+like $@, qr/^Can't modify non-lvalue subroutine call of &utf8::is_utf8 at /,
         'XSUB not seen at compile time dies in lvalue context';
 
 # [perl #119797] else implicitly returning value
-- 
2.5.1

@p5pRT
Copy link
Author

p5pRT commented Oct 6, 2015

From @ilmari

--
"I use RMS as a guide in the same way that a boat captain would use
a lighthouse. It's good to know where it is, but you generally
don't want to find yourself in the same spot." - Tollef Fog Heen

@p5pRT
Copy link
Author

p5pRT commented Oct 8, 2015

From @rurban

On Oct 7, 2015, at 1​:02 AM, Dagfinn Ilmari Mannsåker <ilmari@​ilmari.org> wrote​:

Dagfinn Ilmari Mannsåker (via RT) <perlbug-followup@​perl.org> writes​:

This makes the cause of the error more obvious if you accidentally call
a non-lvalue sub in the final position of an lvalue one.

Suggestion​:
Let’s drop the main​:: prefix when reporting sub names

See e.g. my cperl CV_NAME_NOMAIN patches
perl11/cperl@5105385
perl11/cperl@e3a9b72
perl11/cperl@3b08369

Reini Urban
rurban@​cpan.org

+ namesv = cv_name(cv, NULL, 0);
+ yyerror_pv(Perl_form(aTHX_ "Can't modify non-lvalue "
+ "subroutine call of &%"SVf" in %s",
+ SVfARG(namesv), PL_op_desc[type]),
+ SvUTF8(namesv));
+ return o;

-=item Can't modify non-lvalue subroutine call
+=item Can't modify non-lvalue subroutine call of &%s

-like($_, qr/Can\'t modify non-lvalue subroutine call in scalar assignment/);
+like($_, qr/Can\'t modify non-lvalue subroutine call of &main​::nolv in scalar assignment/);

@p5pRT
Copy link
Author

p5pRT commented Oct 8, 2015

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

@p5pRT
Copy link
Author

p5pRT commented Oct 8, 2015

From @ilmari

Reini Urban <reini.urban@​gmail.com> writes​:

On Oct 7, 2015, at 1​:02 AM, Dagfinn Ilmari Mannsåker <ilmari@​ilmari.org> wrote​:

Dagfinn Ilmari Mannsåker (via RT) <perlbug-followup@​perl.org> writes​:

This makes the cause of the error more obvious if you accidentally call
a non-lvalue sub in the final position of an lvalue one.

Suggestion​:
Let’s drop the main​:: prefix when reporting sub names

That is a orthogonal issue​: we report it in other contexts, so this one
should be consistent.

  $ perl -we 'foo()'
  Undefined subroutine &main​::foo called at -e line 1.

--
"A disappointingly low fraction of the human race is,
at any given time, on fire." - Stig Sandbeck Mathisen

@p5pRT
Copy link
Author

p5pRT commented Oct 8, 2015

From @rurban

On Oct 8, 2015, at 11​:32 AM, Dagfinn Ilmari Mannsåker <ilmari@​ilmari.org> wrote​:

Reini Urban <reini.urban@​gmail.com> writes​:

On Oct 7, 2015, at 1​:02 AM, Dagfinn Ilmari Mannsåker <ilmari@​ilmari.org> wrote​:

Dagfinn Ilmari Mannsåker (via RT) <perlbug-followup@​perl.org> writes​:

This makes the cause of the error more obvious if you accidentally call
a non-lvalue sub in the final position of an lvalue one.

Suggestion​:
Let’s drop the main​:: prefix when reporting sub names

That is a orthogonal issue​: we report it in other contexts, so this one
should be consistent.

$ perl -we 'foo()'
Undefined subroutine &main​::foo called at -e line 1.

Sure. Not talking about your patch which is fine.

I’m talking about on top of your patch, because it reminded me on
the perl5 still ugly warnings and error messages, while mine look much better.

And you touched almost all those places already here.

@p5pRT
Copy link
Author

p5pRT commented Oct 8, 2015

From @ilmari

Reini Urban <reini.urban@​gmail.com> writes​:

On Oct 8, 2015, at 11​:32 AM, Dagfinn Ilmari Mannsåker <ilmari@​ilmari.org> wrote​:

Reini Urban <reini.urban@​gmail.com> writes​:

On Oct 7, 2015, at 1​:02 AM, Dagfinn Ilmari Mannsåker <ilmari@​ilmari.org> wrote​:

Dagfinn Ilmari Mannsåker (via RT) <perlbug-followup@​perl.org> writes​:

This makes the cause of the error more obvious if you accidentally call
a non-lvalue sub in the final position of an lvalue one.

Suggestion​:
Let’s drop the main​:: prefix when reporting sub names

That is a orthogonal issue​: we report it in other contexts, so this one
should be consistent.

$ perl -we 'foo()'
Undefined subroutine &main​::foo called at -e line 1.

Sure. Not talking about your patch which is fine.

I’m talking about on top of your patch, because it reminded me on
the perl5 still ugly warnings and error messages, while mine look much better.

Please start a new thread for that, or even better, file an RT with just
those patches (applicable to current blead, not your fork) to achieve
that.

And you touched almost all those places already here.

I touched only one of the several error mesages that report the sub
name​:

ilmari@​garkbit​:~/src/perl$ ag --cc '(?<!^)\bcv_name\(' | wc -l
11

--
- Twitter seems more influential [than blogs] in the 'gets reported in
  the mainstream press' sense at least. - Matt McLeod
- That'd be because the content of a tweet is easier to condense down
  to a mainstream media article. - Calle Dybedahl

@p5pRT
Copy link
Author

p5pRT commented Oct 12, 2015

From @tonycoz

On Tue Oct 06 16​:03​:16 2015, ilmari wrote​:

Dagfinn Ilmari Mannsåker (via RT) <perlbug-followup@​perl.org> writes​:

This makes the cause of the error more obvious if you accidentally call
a non-lvalue sub in the final position of an lvalue one.

Here's an updated patch which also removes the now-redundant OP_ENTERSUB
case in the default block of the switch.

Thanks, applied as 0f94828.

Tony

@p5pRT
Copy link
Author

p5pRT commented Oct 12, 2015

@tonycoz - 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