Skip to content

Commit

Permalink
allow porting/diag.t to detect messages from XSUBs in class.c
Browse files Browse the repository at this point in the history
and briefly document the undocumented messages it found.

Note that the "Odd number of arguments" message isn't suppressible,
I do not know if that is by design:

  $ ./perl -Ilib -Mfeature=class -e 'no warnings; class C { field $x:param; } C->new("x")'
  Odd number of arguments passed to "C" constructor at -e line 1.

Discovered when porting/diag.t didn't warn about my new message
in the fix for Perl#22159
  • Loading branch information
tonycoz committed Apr 23, 2024
1 parent 17535c9 commit 02d524f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pod/perldiag.pod
Original file line number Diff line number Diff line change
Expand Up @@ -4729,6 +4729,14 @@ regardless of what name the caller used.
(W overload) The call to overload::constant contained an odd number of
arguments. The arguments should come in pairs.

=item Odd number of arguments passed to "%s" constructor

(S) The constructor for the given class was called with an odd
number of arguments.

Class constructors accept named arguments as a list and expect pairs
of name followed by value as if you were initialising a hash.

=item Odd number of elements in anonymous hash

(W misc) You specified an odd number of elements to initialize a hash,
Expand Down Expand Up @@ -7308,6 +7316,11 @@ whereabouts in the regular expression the escape was discovered.
(F) You attempted to add a named attribute to a C<field> definition, but
perl does not recognise the name of the requested attribute.

=item Unrecognised parameters for "%s" constructor: %s

(F) You called new on a class but supplied a parameter name that
didn't match a class field name.

=item Unrecognized signal name "%s"

(F) You specified a signal name to the kill() function that was not
Expand Down
1 change: 1 addition & 0 deletions t/porting/diag.t
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ my $specialformats_re = qr/%$format_modifiers"\s*($specialformats)(\s*(?:"|\z))?
# We skip the bodies of most XS functions, but not within these files
my @include_xs_files = (
"builtin.c",
"class.c",
"universal.c",
);

Expand Down

0 comments on commit 02d524f

Please sign in to comment.