188 Commits

Author SHA1 Message Date
James E Keenan
f430ad845a Fatalization of calling import/unimport method with argument
This commit is mostly a manual reversion of commit f1cf82e.  Return to
using a perl_croak in universal.c; adjust regen/warnings.pl as needed; run 'make
regen'; get t/op/universal.t passing.  No documentation changes yet.

Add test for undefined unimport method, then refactor repeated code into
a subroutine.  Perform a pattern match rather than a string equality
test because testing for exact line numbers inside a test program is too
fragile for maintenance purposes.

'mispelled' was misspelled in one location; correct.  Suppress 'used
only once' warning in one location.  POD formatting improvements as
suggested by Elvin Aslanov, with one other word change.

Correct case of one character in error message so that it's the same in
both universal.c and pod/perldiag.pod.  This enables us to preserve
status of universal.c in t/porting/diag.t.  Per: Tony Cook review.

Rebasing on blead in the wake of d306795336, meant that merge conflicts
appeared, which necessitated two rounds of running 'make regen'.
Simplify test_undefined_method(). Update entry in
pod/perldeprecation.pod.

For: GH #23623
2025-12-19 06:51:32 -05:00
James E Keenan
d306795336 Fatalize use of goto to jump into construct
* Adapt all tests.

* Revise discussion of 'goto' in perlfunc.

* Perl 5.44 fatalization: document goto_construct Also, note that no
  deprecations or fatalizations occurred in perl-5.42.

* Remove 'goto_construct' from list of warnings.  This entails:

** Entering 'deprecated::goto_construct" into %NO_BIT_FOR inside
regen/warnings.pl;

** Incrementing $VERSION in that file;

** Running `make regen` to propagate these changes to lib/warnings.pm and
warnings.h, in the process renumbering the warnings categories and
adding 'deprecated::goto_construct' to %NoOp inside lib/warnings.pm.

* Add entry to perldiag.pod

* Update perldelta: partial fatalization of goto construct.

* t/op/goto.t: Restore tests deleted during work on branch.
2025-12-16 10:13:47 -05:00
Paul "LeoNerd" Evans
f1a8d7d883 Implement named parameters in signatures (PPC0024)
This adds a major new ability to subroutine signatures, allowing callers
to pass parameters by name/value pairs rather than by position.

  sub f ($x, $y, :$alpha, :$beta = undef) { ... }

  f( 123, 456, alpha => 789 );

Originally specified in

  https://github.com/Perl/PPCs/blob/main/ppcs/ppc0024-signature-named-parameters.md

This feature is currently considered experimental.
2025-10-31 11:31:29 +00:00
Paul "LeoNerd" Evans
bf81de7afe Rename the 'any' and 'all' features and experimental warnings to 'keyword_any' and 'keyword_all'
This avoids confusion with the `use feature ':all'` ability

(As requested by https://github.com/Perl/perl5/issues/23104)
2025-03-14 15:54:13 +00:00
Tony Cook
2dd81b7056 undeprecate switch and smartmatch
The deprecation warnings don't appear to have had any tests.
2025-02-16 14:51:17 +01:00
Paul "LeoNerd" Evans
6f04944602 Implement PPC0027: Create all and any operators
As these only permit `any BLOCK LIST` and not the deferred-expression
form like `grep EXPR, LIST`, we create a whole new token type, BLKLSTOP,
to represent these. The parser then only accepts the block form and not
the expression form when parsing these.
2024-12-04 16:28:06 +00:00
Tony Cook
67239d004f remove deprecation of apostrophe in symbol
I'm a little hesitant over the removal of the warning identifier,
since it means code that suppressed the warning in 5.38 and 5.40 will
now see an error, but porting/deprecation complained when I removed
the documentation from pod/perldeprecation.pod but left the warning
in.

An alternative would be to add a "Cancelled Removals" to
perldeprecation.
2024-11-11 10:39:40 +11:00
Graham Knop
c729e47cb9 Revert "Remove experimental warnings from extra paired delimiters"
This properly returns the extra paired delimiters feature to
experimental status.

This reverts commit a09a0269dd243971b28401d82f5214932d0d6c8f.
2024-05-29 08:01:22 +02:00
Paul "LeoNerd" Evans
a09a0269dd Remove experimental warnings from extra paired delimiters 2024-04-11 16:07:33 +01:00
Paul "LeoNerd" Evans
4b6ad5110c Remove experimental warnings from foreach with list of variables 2024-04-11 16:07:33 +01:00
Paul "LeoNerd" Evans
1d1580e58f Remove experimental warnings from sub :const attribute 2024-04-11 16:07:33 +01:00
Paul "LeoNerd" Evans
f7cf35fe95 Bump VERSION in warnings.pm 2024-04-11 16:07:33 +01:00
Lukas Mai
260f3d82ae revert change to regen/warnings.pl
This reverts a version bump made in e63d87953b9ae, which I think was
incorrect: The "subsequent use version" warning appeared in 5.39.8, not
5.39.9.
2024-02-24 16:49:55 +01:00
reneeb
e63d87953b Bump the perl version in various places for 5.39.9 2024-02-23 16:42:39 +01:00
Paul "LeoNerd" Evans
351de214d2 Issue deprecation warnings on subsequent use VERSION declarations 2024-02-20 11:09:56 +00:00
Paul "LeoNerd" Evans
16b59695a6 Fix the added-in field of deprecated::missing_import_called_with_args
This was added in 5.39.2, not the as-yet-unreleased 5.39.10.
2024-02-16 18:03:15 +00:00
Yves Orton
f1cf82e77b universal.c - change import with args error to be a deprecated warning
We have had a LOT of fallout from 2dcf3cf50d7 as it turns out that
there various common cases of people accidentally exploiting the
silent use of missing import with arguments.  The premise of detecting
this was that it would allow us to detect scenarios where users
on a case-insensitive file-system had a typo. But it turns that there
are a lot of accidental cases of this as well, a lot more than we
expected.

Common mistaken cases are:

    * Via use_ok() where people think the second argument is a test
      name instead of an argument to the import of the module being
      used.

    * Using a quoted version number in a version check instead of a true
      number. IE:

        use Foo '1.234';

      gets passed to Foo->import() and not Foo->VERSION(). This is
      compounded by the fact that Exporter->import() *does* support a
      version check via import(). Arguably if we allow string versions
      (IMO we should) then we should deal with this in the parser, not
      in import() (although the latter is a little more debatable IMO).

    * Explicit calls to import() with a version number.

    * Mistakenly requesting an export from a module that doesn't
      actually export anything. One possible explanation for this case
      is that a module was at one point in its lifetime not a class, but
      then was later on turned into a class and the arguments to use
      statements weren't changed even though the main code was
      changed to use class syntax.

Because of the scope of the breakage of the original error this patch
downgrades the error to a depecation warning instead, with the intention
that in 5.44 we will make it a hard error.
2023-07-26 21:25:17 +02:00
Tony Cook
c248715173 bump $warnings::VERSION 2023-07-04 14:01:58 +10:00
Hugo van der Sanden
0a92f3412d squashme: rename stub new to open
Keep things consistent.
2023-07-03 21:04:06 -06:00
Hugo van der Sanden
78d7b3d6aa warnings doc improvements
- fix a couple of typos;
- clarify that 'use warnings' enables even warnings that have not yet
  been registered;
- rename function name in an example, since a later reference relates
  to the same function from a previous example;
- link to a more specific point from warnings::register
2023-07-03 21:04:06 -06:00
Ricardo Signes
bb7d7c52d8 warnings: notes on when deprecated::smartmatch was added
This was broken by version bump, then cascaded into more places.  This
commit reverts the change to warnings.pl and does a regen.
2023-06-11 16:13:49 -04:00
Ricardo Signes
454866b63e version bump: bump warnings.pm version
I am surprised I had to bump the version here, but porting/cmp_version
complained, because of this:

    # Version number (1.64) unchanged since v5.37.11, but contents have changed:
    #
    # diff --git a/lib/warnings.pm b/lib/warnings.pm
    # index 739b51a0ac..45532dd45a 100644
    # --- a/lib/warnings.pm
    # +++ b/lib/warnings.pm
    # @@ -129,7 +129,7 @@ our %Offsets = (
    #      # Warnings Categories added in Perl 5.037009
    #      'deprecated::apostrophe_as_package_separator'=> 156,
    #
    # -    # Warnings Categories added in Perl 5.03701
    # +    # Warnings Categories added in Perl 5.038
    #      'deprecated::smartmatch'		=> 158,
    #  );

This feels like a bit of the regen code that I don't understand.  I'm
making this patch at least tentatively to try to get tests all passing.
2023-06-01 21:12:28 -04:00
Ricardo Signes
f1f3a1eb39 version bump: make regen 2023-06-01 21:12:28 -04:00
Lukas Mai
b7eedb0895 fix incorrect vi filetype declarations in generated files
Vim's filetype declarations are case sensitive. The correct types for
Perl, C, and Pod are perl, c, and pod, respectively.
2023-03-24 06:10:05 +08:00
Yves Orton
b689ed93d1 warnings.pm - add deprecated::version_downgrade category
This also fixes the version_downgrade to show the correct version that
version downgrades will be removed in.
2023-03-18 21:00:54 +08:00
Yves Orton
2d8fceed54 warnings.pm - add deprecated::goto_construct category
This category applies to attempts to goto the internals of a block
construct.
2023-03-18 21:00:54 +08:00
Yves Orton
71e49ade7b warnings.pm - add deprecated::delimiter_will_be_paired category
Some delimiters are considered deprecated because in the future they
will be used as part of a paired delimiter. This adds a new category
for these cases.
2023-03-18 21:00:54 +08:00
Yves Orton
25676a7479 warnings.pm - add deprecated::apostrophe_as_package_separator as new deprecation category
This category is about use of apostrophe as a package separator, eg
for things like "Test::More::isn't()".
2023-03-18 21:00:54 +08:00
Yves Orton
25991c51d4 warnings.pm - support deprecated::unicode_property_name category
This category is only used in the regex engine, we should be able
to disable it specifically, as it seems like we will never actually
remove demove support for the things it warns about.
2023-03-18 21:00:54 +08:00
Yves Orton
21b005c93f warnings.pm - add deprecated::dot_in_inc warings category
Instead of using a generic warnings category switch to fine grained
control.
2023-03-18 21:00:54 +08:00
Yves Orton
d81b4f9331 warnings.pm - support deprecated::smartmatch category
Currently we seem to lack a way to have a subcategory under deprecated.
It seems reasonable to me that people might want to disable a specific
subcategory warning while leaving the rest in place. This patch allows
that. Note that both

    no warnings "deprecated";

and

    no warnings "deprecated::smartmatch";

work to disable the warning. Deprecated warnings shouldn't be "all or
nothing", they should be specific and targetted.
2023-03-18 21:00:54 +08:00
Philippe Bruhat (BooK)
381382f766 Deprecate smartmatch
Make the 'experimental::smartmatch' warning obsolete, and use
'deprecated' instead.
2023-02-25 00:49:18 +08:00
Richard Leach
b625025e93 Prefer scalar assignment to get caller's first return value
Multiple forms of syntax can be used to obtain a package name from
`caller`, which emits this as its first return value, and assign
that name to a lexical scalar.

The following each achieve the same result, but with varying efficiency:
* `sub callme { my $package = caller(2); ...}`
* `sub callme { my ($package) = caller(2); ...}`
* `sub callme { my $package = (caller(2))[0]; ...}`

In the first example, `pp_caller` determines only the package name
and pushes it to the stack. In the other two examples, the other 10 of
`caller`'s return values are calculated and pushed onto the stack,
before being discarded.

This commit changes non-CPAN-first instances of the latter two forms
in core to the first form.

Note: There is a special exception to the equivalence described above,
when caller is use in list context within the DB package. Such a
usage instance in regen/warnings.pl therefore remains unchanged.
2023-02-22 12:58:26 +01:00
Elvin Aslanov
6a3688ca38 generated files - update mode lines to specify file type
This updates the mode-line for most of our generated files so that
they include file type information so they will be properly syntax
highlighted on github.

This does not make any other functional changes to the files.

[Note: Commit message rewritten by Yves]
2023-02-19 09:44:05 +08:00
Paul "LeoNerd" Evans
99b497aa90 Initial attack at basic 'class' feature
Adds a new experimental warning, feature, keywords and enough parsing to
implement basic classes with an empty `new` constructor method.

Inject a $self lexical into method bodies; populate it with the object instance, suitably shifted
Creates a new OP_METHSTART opcode to perform method setup
Define an aux flag to remark which stashes are classes

Basic implementation of fields.

Basic anonymous methods.
2023-02-10 12:07:02 +00:00
Yves Orton
f8552c1a7e cop.h - get rid of the STRLEN* stuff from cop_warnings
With RCPV strings we can use the RCPV_LEN() macro, and
make this logic a little less weird.
2022-11-02 08:49:32 +01:00
Yves Orton
f0774ef1d0 warnings.h - length guard cop_warnings bitvector checks 2022-11-02 08:49:32 +01:00
Philippe Bruhat (BooK)
d7e8a03198 Reclaim unused bits in ${^WARNING_BITS}
`no warnings 'experimental::foo';` is effectively a no-op
if the `foo` feature is not experimental any more.

So, stop reserving bits in `${^WARNING_BITS}` for them,
and silently do nothing when they are enabled or disabled
via `use warnings` or `no warnings`.

Warnings turned into no-op in this commit:
* experimental::alpha_assertions
* experimental::bitwise
* experimental::isa
* experimental::lexical_subs
* experimental::postderef
* experimental::script_run
* experimental::signatures
2022-09-24 14:24:08 +02:00
Karl Williamson
9c9853e81d Add 'extra paired delimiters' feature
When this feature is enabled, one can use many more string delimiters
that have an opening version and a mirrored closing one.
2022-03-19 23:17:51 -06:00
Karl Williamson
737a7c2c21 Remove use of experimental regex sets warnings
These warnings are no longer generated; so simplify the core by not
trying to turn them off.

The warning is preserved so that other code need not change, but this
commit also turns the default generation of it off.
2022-03-19 12:49:28 -06:00
Paul "LeoNerd" Evans
4c58833d27 Add a new 'scalar' warnings category 2022-03-08 20:21:42 +00:00
Paul "LeoNerd" Evans
1c547c3e2c Add a new 'experimental::snail_in_signatures' warning category 2022-01-31 10:03:58 +00:00
Paul "LeoNerd" Evans
59802880d7 Add experimental::builtin warning 2022-01-25 15:02:58 +00:00
Pete Houston
5624cfff8f POD breakage in lib/warnings.pm
An unescaped right angle bracket was resulting in a malformed code snippet in warnings.pm

This tiny PR escapes that character and thus fixes the rendering.

regen/warnings.pl corrected and regenerated; version bumped.

Pete Houston is now a Perl Author.

For: https://github.com/Perl/perl5/pull/19228
2021-11-18 12:30:12 +00:00
Nicholas Clark
3b54923c12 Add a new warning experimental::for_list. 2021-10-15 09:28:27 -04:00
Paul "LeoNerd" Evans
f79e2ff95f Create defer syntax and OP_PUSHDEFER opcode
Adds syntax `defer { BLOCK }` to create a deferred block; code that is
deferred until the scope exits. This syntax is guarded by

  use feature 'defer';

Adds a new opcode, `OP_PUSHDEFER`, which is a LOGOP whose `op_other` field
gives the start of an optree to be deferred until scope exit. That op
pointer will be stored on the save stack and invoked as part of scope
unwind.

Included is support for `B::Deparse` to deparse the optree back into
syntax.
2021-08-25 13:52:09 +01:00
Ben Cornett
1c3cfd8769 Document v5.35 warnings-on-by-default 2021-08-15 13:40:54 +02:00
Leon Timmermans
ce45800fdb Remove :win32 PerlIO layer 2021-06-28 08:47:57 -06:00
Paul "LeoNerd" Evans
a1325b902d Initial attempt at feature 'try'
* Add feature, experimental warning, keyword
 * Basic parsing
 * Basic implementation as optree fragment

See also
  https://github.com/Perl/perl5/issues/18504
2021-02-04 14:20:53 +00:00
James E Keenan
01900a5f23 Additional guidance against "FATAL => 'all'".
For: https://github.com/Perl/perl5/pull/18385
2021-01-30 21:21:04 +00:00