Switch feature does not work with 0.004 #3

Open
asolovey opened this Issue May 7, 2013 · 0 comments

Comments

Projects
None yet
1 participant

asolovey commented May 7, 2013

After upgrading to 0.004, Test::Vars complains that "$_ used only once" for code with 'switch' feature. Below is simple code to demonstrate it:

package Switch;
use strict;
use warnings 'once';
use feature 'switch';
sub foo {
    my $x = shift;
    given( $x ) {
        return 1 when /foo/;
        return 2 when /bar/;
        default {
            return 0;
        }
    }
    return;
}
1;

Adding this module to the t/lib/ and t/02_warnings.t produces the following error:
t/02_no_warnings.t .. 1/? # Test::Vars ignores CompileError.pm because: Intentional compile error.
# $_ is used once in &Switch::foo
# Failed test 't/lib/Switch.pm'
# at t/02_no_warnings.t line 19.
# Looks like you failed 1 test of 26.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment