Subject: Updated regexp for HEAD version and test case

From: "Giuliano Procida" <[email-masked]>
Date: Sat, 29 Mar 2008 19:30:56 +0000

The patch I sent was broken. In any case it looks like the latest HEAD
has a completely different regexp:

    ;; Funny things in sub arg specifications like `sub myfunc ($$)'
    ;; Be careful not to match "sub { (...) ... }".
    ("\\<sub[[:space:]]+[^{}[:punct:][:space:]]+[[:space:]]*(\\([^)]+\\))"
1 '(1))

This should be (untested):

    ;; Funny things in sub arg specifications like `sub myfunc ($$)'
and `sub ($)'
    ;; Be careful not to match "sub { (...) ... }".
    ("\\<sub\\([[:space:]]+[^{}[:punct:][:space:]]+\\)?[[:space:]]*(\\([^)]+\\))"
1 '(1))

Here is a simple test case.

#!/usr/bin/perl

use strict;
use warnings;

# the $ in the next line has syntax-table (1)
sub add ($) {
    my ($a) = @_;
    # the $ in the next line does not
    return sub ($) {
        my ($b) = @_;
        return $a+$b;
        # the brace on the next line will be misindented on TAB
    };
}

# the following line will also be misindented on TAB
print "1+2=", &{add(1)}(2), "\n";

Regards,
Giuliano Procida.