Skip to content

Conversation

@iabyn
Copy link
Contributor

@iabyn iabyn commented Nov 12, 2025

Ironically, this warns:

$ perl -e'use warnings; undef $^W'
Use of uninitialized value in undef operator at -e line 1.
$

The magic-setting code was treating the new value of $^W as an integer. This commit makes it treat the value as a boolean.

I suppose this commit could in theory break code if that code is doing something like:

$^W = "0 but true";

In the past that would have disabled warnings, but will now enable them. But it seems unlikely that anyone would have written such code. The variable is documented in perlvar as having a value which is interpreted as a boolean.

Note that this commit stops a test in t/op/reset.t from expecting a warning when resetting $^W. This test was added by issue GH #20763, and AFAIKT that ticket was concerned with 'reset $^W' not actually resetting the variable; the test for the warning was purely a side-effect of the fact that it happened to warn.

  • This set of changes does not require a perldelta entry.

Ironically, this warns:

    $ perl -e'use warnings; undef $^W'
    Use of uninitialized value in undef operator at -e line 1.
    $

The magic-setting code was treating the new value of $^W as an integer.
This commit makes it treat the value as a boolean.

I suppose this commit could in theory break code if that code is
doing something like:

    $^W = "0 but true";

In the past that would have disabled warnings, but will now enable them.
But it seems unlikely that anyone would have written such code. The
variable is documented in perlvar as having a value which is interpreted
as a boolean.

Note that this commit stops a test in t/op/reset.t from expecting a
warning when resetting $^W. This test was added by issue GH #20763, and
AFAIKT that ticket was concerned with 'reset $^W' not actually
resetting the variable; the test for the warning was purely a
side-effect of the fact that it happened to warn.
Copy link
Contributor

@tonycoz tonycoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was added by issue GH #20763, and AFAIKT that ticket was concerned with 'reset $^W' not actually resetting the variable; the test for the warning was purely a side-effect of the fact that it happened to warn.

Pretty much.

@iabyn iabyn merged commit 00f271f into blead Nov 13, 2025
68 checks passed
@iabyn iabyn deleted the davem/undef_caret_W branch November 13, 2025 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants