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

Wrong error message for default outside a topicalizer #11377

Closed
p5pRT opened this issue May 24, 2011 · 16 comments
Closed

Wrong error message for default outside a topicalizer #11377

p5pRT opened this issue May 24, 2011 · 16 comments

Comments

@p5pRT
Copy link

p5pRT commented May 24, 2011

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

Searchable as RT91514$

@p5pRT
Copy link
Author

p5pRT commented May 24, 2011

From @sciurius

Created by @sciurius

  #!/usr/bin/perl
  use strict;
  use warnings;
  use 5.14.0;
  default { say "Hello!" }

prints "Hello!" and then aborts with​:

  Can't use when() outside a topicalizer at ...

Perl Info

Flags:
    category=core
    severity=medium

Site configuration information for perl 5.14.0:

Configured by jv at Wed May  4 19:54:10 CEST 2011.

Summary of my perl5 (revision 5 version 14 subversion 0) configuration:
   
  Platform:
    osname=linux, osvers=2.6.35.12-90.fc14.i686.pae, archname=i386-linux-thread-multi
    uname='linux phoenix.squirrel.nl 2.6.35.12-90.fc14.i686.pae #1 smp fri apr 22 16:08:03 utc 2011 i686 i686 i386 gnulinux '
    config_args='-des -Darchname=i386-linux -Dprefix=/opt/perl-5.14.0-RC2 -Dcf_email=jvromans@squirrel.nl -Dperladmin=jvromans@squirrel.nl -Uversiononly -Dusethreads -Duseithreads -Dusedevel'
    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.5.1 20100924 (Red Hat 4.5.1-4)', 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 /usr/lib
    libs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=/lib/libc-2.13.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.13'
  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:
    RC2


@INC for perl 5.14.0:
    /opt/perl-5.14.0-RC2/lib/site_perl/5.14.0/i386-linux-thread-multi
    /opt/perl-5.14.0-RC2/lib/site_perl/5.14.0
    /opt/perl-5.14.0-RC2/lib/5.14.0/i386-linux-thread-multi
    /opt/perl-5.14.0-RC2/lib/5.14.0
    .


Environment for perl 5.14.0:
    HOME=/home/jv
    LANG=en_US.utf-8
    LANGUAGE (unset)
    LC_PAPER=nl_NL
    LC_TIME=en_GB
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=.:/home/jv/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin
    PERL5LIB=
    PERL_BADLANG (unset)
    SHELL=/bin/tcsh

-- 
----------------------------------------------------------------------------
Johan Vromans                                           jvromans@squirrel.nl
Squirrel Consultancy                                  Exloo, the Netherlands
http://www.squirrel.nl                              http://johan.vromans.org
PGP Key 1024D/1298C2B4                  http://johan.vromans.org/pgpkey.html
----------------------- "Arms are made for hugging" ------------------------

@p5pRT
Copy link
Author

p5pRT commented Dec 15, 2011

From @jkeenan

On Tue May 24 05​:37​:20 2011, jv wrote​:

#!/usr/bin/perl
use strict;
use warnings;
use 5.14.0;
default { say "Hello!" }

prints "Hello!" and then aborts with​:

Can't use when() outside a topicalizer at ...

What would be a better message -- and how should it be classified
according to the scale in 'pod/perldiag.pod'?

  (W) A warning (optional).
  (D) A deprecation (enabled by default).
  (S) A severe warning (enabled by default).
  (F) A fatal error (trappable).

Thank you very much.
Jim Keenan

@p5pRT
Copy link
Author

p5pRT commented Dec 15, 2011

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

@p5pRT
Copy link
Author

p5pRT commented Dec 15, 2011

From @cpansprout

On Wed Dec 14 17​:57​:27 2011, jkeenan wrote​:

On Tue May 24 05​:37​:20 2011, jv wrote​:

#!/usr/bin/perl
use strict;
use warnings;
use 5.14.0;
default { say "Hello!" }

prints "Hello!" and then aborts with​:

Can't use when() outside a topicalizer at ...

What would be a better message

Can't use default outside a topicalizer...?

-- and how should it be classified
according to the scale in 'pod/perldiag.pod'?

       \(W\) A warning \(optional\)\.
       \(D\) A deprecation \(enabled by default\)\.
       \(S\) A severe warning \(enabled by default\)\.
       \(F\) A fatal error \(trappable\)\.

(F)

Thank you very much.
Jim Keenan

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Dec 15, 2011

From @sciurius

[Quoting Father Chrysostomos via RT, on December 14 2011, 18​:08, in "[perl #91514] Wrong "]

Can't use default outside a topicalizer...?

Can't use default{} outside a topicalizer...?

(F)

Yes.

-- Johan

@p5pRT
Copy link
Author

p5pRT commented Dec 16, 2011

From @ap

* Johan Vromans <jvromans@​squirrel.nl> [2011-12-15 08​:00]​:

* Father Chrysostomos via RT <perlbug-followup@​perl.org> [2011-12-15 03​:10]​:

On Wed Dec 14 17​:57​:27 2011, jkeenan wrote​:

On Tue May 24 05​:37​:20 2011, jv wrote​:

#!/usr/bin/perl
use strict;
use warnings;
use 5.14.0;
default { say "Hello!" }

prints "Hello!" and then aborts with​:

Can't use when() outside a topicalizer at ...

What would be a better message

Can't use default outside a topicalizer...?

Can't use default{} outside a topicalizer...?

  $ perl -econtinue
  Can't "continue" outside a when block at -e line 1.
  $ perl -enext
  Can't "next" outside a loop block at -e line 1.

I think the errors for `when` and `default` should follow that style​:

  Can't "when" outside a topicalizer at ...
  Can't "default" outside a topicalizer at ...

Regards,
--
Aristotle Pagaltzis // <http​://plasmasturm.org/>

@p5pRT
Copy link
Author

p5pRT commented Dec 16, 2011

From @sciurius

[Quoting A. Pagaltzis via RT, on December 15 2011, 21​:09, in "Re​: [perl #91514] Wr"]

$ perl \-econtinue
Can't "continue" outside a when block at \-e line 1\.

Oh yes, I can​:

  perl -e "for(1){}continue{}"

Can't "when" outside a topicalizer at \.\.\.
Can't "default" outside a topicalizer at \.\.\.

+1

-- Johan

@p5pRT
Copy link
Author

p5pRT commented Dec 16, 2011

From @ap

Hi Johan,

* Johan Vromans <jvromans@​squirrel.nl> [2011-12-16 08​:35]​:

[Quoting A. Pagaltzis via RT, on December 15 2011, 21​:09, in "Re​: [perl #91514] Wr"]

$ perl \-econtinue
Can't "continue" outside a when block at \-e line 1\.

Oh yes, I can​:

perl -e "for(1){}continue{}"

That’s different, it’s a `continue` block. The runtime error message is
talking about the `continue` statement introduced for falling through
from a `when` block. Yes, the ambiguity is annoying.

The error for putting that one in the wrong context is very different​:

  $ perl -e'continue{}'
  syntax error at -e line 1, near "continue"

I find it annoying personally that `when` and `default` are dynamically
scoped and therefore misplacing them cannot similarly be a compile time
syntax error. The scoping of `given`, `when`, and `continue`/`break`
follows nothing else that already existed in Perl, for no substantial
reason I can think of, and smart-match broke the operator monorphism
axiom of Perl. The whole combination of additions feels like a foreign
body in the language.

(I find it difficult to constrain myself to the point at hand when
I touch on the subject because it just feels all so wrong.)

Regards,
--
Aristotle Pagaltzis // <http​://plasmasturm.org/>

@p5pRT
Copy link
Author

p5pRT commented Dec 16, 2011

From @sciurius

[Quoting A. Pagaltzis via RT, on December 16 2011, 02​:47, in "Re​: [perl #91514] Wr"]

(I find it difficult to constrain myself to the point at hand when
I touch on the subject because it just feels all so wrong.)

Yes, I recognise this...

-- Johan

@p5pRT
Copy link
Author

p5pRT commented Dec 16, 2011

From @cpansprout

On Thu Dec 15 23​:32​:28 2011, jv wrote​:

[Quoting A. Pagaltzis via RT, on December 15 2011, 21​:09, in "Re​:
[perl #91514] Wr"]

$ perl \-econtinue
Can't "continue" outside a when block at \-e line 1\.

Oh yes, I can​:

perl -e "for(1){}continue{}"

Can't "when" outside a topicalizer at \.\.\.
Can't "default" outside a topicalizer at \.\.\.

+1

Done with commit fc7debf.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Dec 16, 2011

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

@p5pRT p5pRT closed this as completed Dec 16, 2011
@p5pRT
Copy link
Author

p5pRT commented Dec 20, 2011

From perl-diddler@tlinx.org

James E Keenan via RT wrote​:

On Tue May 24 05​:37​:20 2011, jv wrote​:

#!/usr/bin/perl
use strict;
use warnings;
use 5.14.0;
default { say "Hello!" }

prints "Hello!" and then aborts with​:

Can't use when() outside a topicalizer at ...

Has anyone considered that 'topicalizer' is complete jargon rubish?

Try using *concrete* terms in a error messages, like Can't use when outside
of a given or while block, (are there others?)... but topicalizer????

ARRRGGG!!!

How about we just cut to the end of this trend and start printing things
like "ABEND 47102".

@p5pRT
Copy link
Author

p5pRT commented Dec 20, 2011

From @ikegami

On Mon, Dec 19, 2011 at 8​:37 PM, Linda Walsh <perl-diddler@​tlinx.org> wrote​:

**

James E Keenan via RT wrote​:

On Tue May 24 05​:37​:20 2011, jv wrote​:

 \#\!/usr/bin/perl

use strict;
use warnings;
use 5.14.0;
default { say "Hello!" }

prints "Hello!" and then aborts with​:

Can't use when() outside a topicalizer at ...

Has anyone considered that 'topicalizer' is complete jargon rubish?

Try using **concrete** terms in a error messages, like Can't use when
outside
of a given or while block, (are there others?)... but topicalizer????

given, for, map and grep ...except not the last two.

$ perldoc perlsyn | grep -i topical || echo 'not found'
not found

@p5pRT
Copy link
Author

p5pRT commented Dec 20, 2011

From @b2gills

On Mon, Dec 19, 2011 at 7​:55 PM, Eric Brine <ikegami@​adaelis.com> wrote​:

On Mon, Dec 19, 2011 at 8​:37 PM, Linda Walsh <perl-diddler@​tlinx.org> wrote​:

James E Keenan via RT wrote​:

On Tue May 24 05​:37​:20 2011, jv wrote​:

#!/usr/bin/perl
use strict;
use warnings;
use 5.14.0;
default { say "Hello!" }

prints "Hello!" and then aborts with​:

Can't use when() outside a topicalizer at ...

Has anyone considered that 'topicalizer' is complete jargon rubish?

Try using *concrete* terms in a error messages, like Can't use when
outside
of a given or while block, (are there others?)... but topicalizer????

given, for, map and grep ...except not the last two.

$ perldoc perlsyn | grep -i topical || echo 'not found'
not found

Well this is screwy​:

  $> perl -E'say grep { when("a"){} } "a".."d"'
  Can't use when() outside a topicalizer at -e line 1.

  $> perl -E'say grep { when("b"){} } "a".."d"'
  Can't use when() outside a topicalizer at -e line 1.

  $> perl -E'say grep { when("c"){} } "a".."d"'
  ab

  $> perl -E'say grep { when("d"){} } "a".."d"'
  ab

  $> perl -E'say grep { when("d"){}; 1 } "a".."d"'
  Can't use when() outside a topicalizer at -e line 1.

  $> perl -E'say grep { when("a"){...} } "a".."d"'
  Unimplemented at -e line 1.

  $> perl -E'say grep { when("c"){...} } "a".."d"'
  ab

  $> perl -E'say grep { when("d"){}; say } "a".."d"'
  a
  b
  c
  Can't use when() outside a topicalizer at -e line 1.

  $> perl -E'say grep { when("e"){}; say } "a".."d"'
  a
  b
  c
  d
  abcd

  $&gt; perl -E'say $]'
  5.014001

It doesn't matter what is inside of the `when` block.
It only works properly when it isn't the only thing inside of the `grep` block.
Even then It only fails upon a successful match.

@p5pRT
Copy link
Author

p5pRT commented Dec 20, 2011

From @cpansprout

On Mon Dec 19 18​:30​:16 2011, b2gills@​gmail.com wrote​:

Well this is screwy​:

...

Could you open a new ticket?

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Dec 20, 2011

From [Unknown Contact. See original ticket]

On Mon Dec 19 18​:30​:16 2011, b2gills@​gmail.com wrote​:

Well this is screwy​:

...

Could you open a new ticket?

--

Father Chrysostomos

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