houseabsolute / p5-Test-Vars

Detects unused variables in unit tests
https://metacpan.org/pod/Test::Vars
Other
6 stars 10 forks source link

\(my $var) is not an unused variable (RT 82411) #55

Open jkeenan opened 6 days ago

jkeenan commented 6 days ago

Transferred from rt.cpan.org ...

Original Ticket Information

Original Text

When a reference to a variable is used it should not be considered unused.

There is a common idiom when declaring an empty object which internal representation is a scalar:

    bless do { \(my $x) }, $class

or

    bless \(my $y), $class

Currently $x is reported as unused, while it is.

Follow-up Report (same date as original)

Workaround:

do { my $x; bless \($x), $class }