houseabsolute / Params-ValidationCompiler

Build an optimized subroutine parameter validator once, use it forever
https://metacpan.org/release/Params-ValidationCompiler/
Other
4 stars 5 forks source link

Moose test Fails if Moose::Meta::TypeConstraint is too old? #26

Closed vollink closed 2 years ago

vollink commented 2 years ago

Hi Dave,

Maybe this is something weird on my system, but it seems likely to be Moose version related.

VERSIONS: perl-5.010001 (5.10.1) Params-Validation-Compiler 0.30

I happened to have stumbled on this on a system with Moose Version 1.15 (same version set in Moose::Meta::TypeConstraint). Not sure the approach to fix or even verify what I'm looking at.

The rest is inlined below from the MYMETA.yaml block dump.

The tests that failed...

t/moose.t ................ 1/? 
# Failed test 'type can be inlined'
# at t/moose.t line 18.
# Caught exception in subtest: Unknown type object Moose::Meta::TypeConstraint at t/moose.t line 91

# Failed test 'type cannot be inlined'
# at t/moose.t line 26.
# Caught exception in subtest: Unknown type object Moose::Meta::TypeConstraint at t/moose.t line 91

# Failed test 'type can be inlined but coercion cannot'
# at t/moose.t line 36.
# Caught exception in subtest: Unknown type object Moose::Meta::TypeConstraint::Parameterizable at t/moose.t line 114

# Failed test 'neither type not coercion can be inlined'
# at t/moose.t line 46.
# Caught exception in subtest: Unknown type object Moose::Meta::TypeConstraint::Parameterizable at t/moose.t line 114

# Failed test 'enum type'
# at t/moose.t line 64.
# Caught exception in subtest: Unknown type object Moose::Meta::TypeConstraint::Enum at t/moose.t line 53

# Failed test 'empty enum subtype'
# at t/moose.t line 84.
# Caught exception in subtest: Unknown type object Moose::Meta::TypeConstraint at t/moose.t line 73
# Seeded srand with seed '20220628' from local date.
t/moose.t ................ Dubious, test returned 6 (wstat 1536, 0x600)
Failed 6/6 subtests 

No mention of Moose namespace in the rest of the relevant VERSIONS...

# Versions for all modules listed in MYMETA.json (including optional ones):
# 
# === Configure Requires ===
# 
#     Module              Want Have
#     ------------------- ---- ----
#     ExtUtils::MakeMaker  any 7.64
# 
# === Build Requires ===
# 
#     Module              Want Have
#     ------------------- ---- ----
#     ExtUtils::MakeMaker  any 7.64
# 
# === Test Requires ===
# 
#     Module                        Want     Have
#     ------------------------- -------- --------
#     ExtUtils::MakeMaker            any     7.64
#     File::Spec                     any     3.75
#     Hash::Util                     any     0.07
#     Specio                        0.14     0.48
#     Test2::Plugin::NoWarnings      any     0.09
#     Test2::Require::Module         any 0.000145
#     Test2::V0                      any 0.000145
#     Test::More                1.302015 1.302190
#     Test::Without::Module          any     0.20
# 
# === Test Recommends ===
# 
#     Module         Want     Have
#     ---------- -------- --------
#     CPAN::Meta 2.120900 2.143240
# 
# === Runtime Requires ===
# 
#     Module           Want Have
#     ---------------- ---- ----
#     B                 any 1.22
#     Carp              any 1.11
#     Eval::Closure     any 0.08
#     Exception::Class  any 1.29
#     Exporter          any 5.74
#     List::Util       1.29 1.62
#     Scalar::Util      any 1.62
#     overload          any 1.07
#     strict            any 1.04
#     warnings          any 1.06
# 
# === Runtime Recommends ===
# 
#     Module            Want    Have
#     ----------------- ---- -------
#     Class::XSAccessor  any missing
#     Sub::Util         1.40    1.62
# 

The final thing I did was add a Data::Dumper->dump to _test_int_type in moose.t, just to show what this is actually choking on...

$type = bless( {
                 'compiled_type_constraint' => sub { "DUMMY" },
                 'parent' => bless( {
                                      'compiled_type_constraint' => sub { "DUMMY" },
                                      'parent' => bless( {
                                                           'compiled_type_constraint' => sub { "DUMMY" },
                                                           'parent' => bless( {
                                                                                'compiled_type_constraint' => sub { "DUMMY" },
                                                                                'parent' => bless( {
                                                                                                     'compiled_type_constraint' => sub { "DUMMY" },
                                                                                                     'parent' => bless( {
                                                                                                                          'compiled_type_constraint' => sub { "DUMMY" },
                                                                                                                          'parent' => bless( {
                                                                                                                                               'compiled_type_constraint' => sub { "DUMMY" },
                                                                                                                                               'name' => 'Any',
                                                                                                                                               'constraint' => sub { "DUMMY" },
                                                                                                                                               'package_defined_in' => 'Moose::Util::TypeConstraints'
                                                                                                                                             }, 'Moose::Meta::TypeConstraint' ),
                                                                                                                          'name' => 'Item',
                                                                                                                          'constraint' => sub { "DUMMY" },
                                                                                                                          'package_defined_in' => 'Moose::Util::TypeConstraints'
                                                                                                                        }, 'Moose::Meta::TypeConstraint' ),
                                                                                                     'name' => 'Defined',
                                                                                                     'constraint' => sub { "DUMMY" },
                                                                                                     'package_defined_in' => 'Moose::Util::TypeConstraints'
                                                                                                   }, 'Moose::Meta::TypeConstraint' ),
                                                                                'hand_optimized_type_constraint' => $type->{'parent'}{'parent'}{'parent'}{'compiled_type_constraint'},
                                                                                'name' => 'Value',
                                                                                'constraint' => sub { "DUMMY" },
                                                                                'package_defined_in' => 'Moose::Util::TypeConstraints'
                                                                              }, 'Moose::Meta::TypeConstraint' ),
                                                           'hand_optimized_type_constraint' => $type->{'parent'}{'parent'}{'compiled_type_constraint'},
                                                           'name' => 'Str',
                                                           'constraint' => sub { "DUMMY" },
                                                           'package_defined_in' => 'Moose::Util::TypeConstraints'
                                                         }, 'Moose::Meta::TypeConstraint' ),
                                      'hand_optimized_type_constraint' => $type->{'parent'}{'compiled_type_constraint'},
                                      'name' => 'Num',
                                      'constraint' => sub { "DUMMY" },
                                      'package_defined_in' => 'Moose::Util::TypeConstraints'
                                    }, 'Moose::Meta::TypeConstraint' ),
                 'hand_optimized_type_constraint' => $type->{'compiled_type_constraint'},
                 'name' => 'Int',
                 'constraint' => sub { "DUMMY" },
                 'package_defined_in' => 'Moose::Util::TypeConstraints'
               }, 'Moose::Meta::TypeConstraint' );

If there's anything else I can add to help categorize this issue and tell me the best way forward on helping to get it fixed (even if it's just a documentation fix), please do let me know. I will fully accept any form of "if you'd have read X" as I'm well aware I can get tunnel vision at times like this.

Thank you, Gary Allen Vollink

autarch commented 2 years ago

I think the fix is simply to make the test require a newer version of Moose. I'll push a change to require 2.0000+ in that test. Thanks for the report!