# does not look like a prototype, we assume it is a SIGNATURE and we
# will stop and let the the standard tokenizer handle it. In
# particular, we stop if we see any nested parens, braces, or commas.
- # Note, a valid prototype cannot contain any alphabetic character
- # see https://perldoc.perl.org/perlsub
- # But it appears that an underscore may be valid now
+ # Also note, a valid prototype cannot contain any alphabetic character
+ # -- see https://perldoc.perl.org/perlsub
+ # But it appears that an underscore may be valid now, so this is
+ # using [A-Za-z] instead of \w
my $saw_opening_paren = $input_line =~ /\G\s*\(/;
if (
- ## FIXME: this should be the future version after some
- ## problems are resolved
- ## $input_line =~ m/\G(\s*\([^\)\(\}\{\,#A-Za-z]*\))? # PROTO
- $input_line =~ m/\G(\s*\([^\)\(\}\{\,#]*\))? # PROTO
+ $input_line =~ m/\G(\s*\([^\)\(\}\{\,#A-Za-z]*\))? # PROTO
(\s*:)? # ATTRS leading ':'
/gcx
&& ( $1 || $2 )
=head1 Issues fixed after release 20201001
+=item b<sub signatures no longer parsed with prototypes>
+
+Simple signatures were being parsed with the code for prototypes, which
+prevented them from being formatted with the usual formatting rules. All
+signatures are now formatted separately from prototypes with the normal
+formatting rules. For example:
+
+ # Old, intput and after formatting:
+ sub t123 ($list=wantarray) { $list ? "list" : "scalar" }
+
+ # New, after formatting
+ sub t123 ( $list = wantarray ) { $list ? "list" : "scalar" }
+
+Notice that some spaces have been introduced within the signature. Previously
+the contents of the parens was left unchanged.
+
=item b<fix parsing problem with $#>
A problem with parsing variables of the form $# and $#array was found in
) #foo)))
{ $a.$b }
-The parenthesized expression in the snippet below was parsed as a prototype
-rather than a signature. This was fixed.
-
- sub echo ( $message = 'Hello World!' ) {
- print "$message\n";
- }
=item b<improve guess for pattern or division>
-sub classify_digit($digit) {
+sub classify_digit ($digit) {
switch ($digit) {
case 0 { return 'zero' }
case [ 2, 4, 6, 8 ]{ return 'even' }
source => "switch1",
params => "def",
expect => <<'#3...........',
-sub classify_digit($digit) {
+sub classify_digit ($digit) {
switch ($digit) {
case 0 { return 'zero' }
case [ 2, 4, 6, 8 ]{ return 'even' }