Skip Menu |

This queue is for tickets about the Fun CPAN distribution.

Report information
The Basics
Id: 80694
Status: new
Priority: 0/
Queue: Fun

People
Owner: Nobody in particular
Requestors: MAUKE [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: 0.05
Fixed in: (no value)



Subject: scoping of default arguments slightly weird
$ cat bug/scope #!perl use warnings; use strict; use Fun; my $x = "outer"; fun foo($x = $x) { $x } print foo, "\n"; print foo("inner"), "\n"; __END__ $ perl bug/scope Use of uninitialized value in print at bug/scope line 7. inner I would have expected this to print "outer\ninner\n" because when you say 'my $x = $x;' Perl will use the $x from the surrounding scope to initialize the new lexical $x. But in fun parameter lists, it seems the parameters are in scope during their own declaration. Similarly: $ cat bug/scope2 #!perl use warnings; use strict; use Fun; fun foo($x = $x) {} __END__ $ perl bug/scope2 $ I would have expected this to complain about "Global symbol "$x" requires explicit package name".