Subject: | 2.002002 breaks MongoDB: BUILDARGS did not return a hashref at t/bson_codec/elements.t line 61 |
After upgrading Moo from 2.001001 to 2.002003, a MongoDB-v1.4.2 test fails:
[test@fedora-25 MongoDB-v1.4.2]$ perl -I/tmp/Moo/lib -Iblib/{lib,arch} t/bson_codec/elements.t
BUILDARGS did not return a hashref at t/bson_codec/elements.t line 61.
The t/bson_codec/elements.t:61 line is:
my $dbref = MongoDB::DBRef->new( db => 'test', ref => 'test_coll', id => '123' );
and MongoDB::DBRef around BUILDARGS looks fine:
around BUILDARGS => sub {
my $orig = shift;
my $class = shift;
my $hr = $class->$orig(@_);
return {
id => (
exists( $hr->{'$id'} ) ? delete $hr->{'$id'}
: exists( $hr->{id} ) ? delete $hr->{id}
: undef
),
ref => (
exists( $hr->{'$ref'} ) ? delete $hr->{'$ref'}
: exists( $hr->{ref} ) ? delete $hr->{ref}
: undef
),
db => (
exists( $hr->{'$db'} ) ? delete $hr->{'$db'}
: exists( $hr->{db} ) ? delete $hr->{db}
: undef
),
extra => $hr,
};
};
So I think it's a bug in Moo. I bisected the regression to the following commit range.
First failing commit is:
commit 84b6760de8224ee3a020207e08c22810530e417e
Author: Graham Knop <haarg@haarg.org>
Date: Thu Apr 14 16:50:30 2016 -0400
fix croak location for inlined BUILDARGS
[test@fedora-25 MongoDB-v1.4.2]$ perl -I/tmp/Moo/lib -Iblib/{lib,arch} t/bson_codec/elements.t
Can't use string ("MongoDB::DBRef") as a HASH ref while "strict refs" in use at (eval 256) line 18, <DATA> line 1.
But it's a different error message. First commit with the the same error as in 2.002002 is:
commit 033241619fa2036c4cc23a3e93940dabf68193e6
Author: Graham Knop <haarg@haarg.org>
Date: Thu Jun 23 03:46:18 2016 -0400
prevent local functions from interfering with generated code
Perl debugger reports on the 84b6760de8224ee3a020207e08c22810530e417e commit:
Can't use string ("MongoDB::DBRef") as a HASH ref while "strict refs" in use at (eval 259)[/tmp/Moo/lib/Sub/Quote.pm:3] line 18, <DATA> line 1.
at (eval 259)[/tmp/Moo/lib/Sub/Quote.pm:3] line 18, <DATA> line 1.
MongoDB::DBRef::ref("MongoDB::DBRef") called at (eval 688)[/tmp/Moo/lib/Sub/Quote.pm:3] line 22
MongoDB::DBRef::new("MongoDB::DBRef", "db", "test", "ref", "test_coll", "id", 123) called at t/bson_codec/elements.t line 61
It looks like something wrong happens in the Sub::Quote.