Allow :isa in class declaration without a block

Using class attributes in the unit class syntax was a syntax error. This change makes the following two lines equivalent:

class B :isa(A) ;
class B :isa(A) { }

Addresses GH issue #20888.
This commit is contained in:
Arne Johannessen 2023-03-02 14:56:59 +01:00 committed by Paul Evans
parent 49830b9d6d
commit edcf480ecf
7 changed files with 985 additions and 962 deletions

View File

@ -134,6 +134,7 @@ Aristotle Pagaltzis <pagaltzis@gmx.de>
Arjen Laarhoven <arjen@nl.demon.net>
Arkturuz <arkturuz@gmail.com>
Arne Ahrend <aahrend@web.de>
Arne Johannessen <ajnn@cpan.org>
Arnold D. Robbins <arnold@gnu.ai.mit.edu>
Art Green <Art_Green@mercmarine.com>
Art Haas <ahaas@airmail.net>

499
perly.act generated

File diff suppressed because it is too large Load Diff

2
perly.h generated
View File

@ -235,6 +235,6 @@ int yyparse (void);
/* Generated from:
* 404f5c053415e3ead8d5b0e39c35188e47e522bbccd25374bdcf5128f1b93ccc perly.y
* 772de3ed75dc4010fd79a22e9c90253232ab5af632d3657c55a670d510ee71ef perly.y
* acf1cbfd2545faeaaa58b1cf0cf9d7f98b5be0752eb7a54528ef904a9e2e1ca7 regen_perly.pl
* ex: set ro ft=C: */

1424
perly.tab generated

File diff suppressed because it is too large Load Diff

View File

@ -443,13 +443,16 @@ barestmt: PLUGSTMT
package_version($version);
$$ = NULL;
}
| KW_CLASS BAREWORD[version] BAREWORD[package] PERLY_SEMICOLON
| KW_CLASS BAREWORD[version] BAREWORD[package] subattrlist PERLY_SEMICOLON
{
package($package);
if ($version)
package_version($version);
$$ = NULL;
class_setup_stash(PL_curstash);
if ($subattrlist) {
class_apply_attributes(PL_curstash, $subattrlist);
}
}
| KW_USE_or_NO startsub
{ CvSPECIAL_on(PL_compcv); /* It's a BEGIN {} */ }

View File

@ -366,6 +366,12 @@ manager will later use a regex to expand these into links.
=item *
In the new experimental C<class> feature, attributes are no longer a syntax
error when using the unit class syntax.
[GH #20888].
=item *
XXX
=back

View File

@ -71,4 +71,14 @@ no warnings 'experimental::class';
is($obj->x, "X", 'Constructor params passed through to superclass');
}
{
class Test4A { }
class Test4B :isa(Test4A);
package main;
my $obj = Test4B->new;
ok($obj isa Test4A, 'Unit class syntax allows :isa');
}
done_testing;