Subject: | isa failure text doesn't use the value of init_arg to identify the attribute |
The isa check uses the attribute name specified as the second argument to has when generating an error message instead of the name specified by init_arg. This can confuse the caller as typically the name specified by init_arg is the one which is documented.
For example:
$ { package Foo; use Moo; has x => ( is => 'rw', init_arg => 'y', isa => sub { die( "invalid\n" ); } ) }
$ Foo->new( y => 1 )
Runtime error: isa check for "x" failed: invalid
For example:
$ { package Foo; use Moo; has x => ( is => 'rw', init_arg => 'y', isa => sub { die( "invalid\n" ); } ) }
$ Foo->new( y => 1 )
Runtime error: isa check for "x" failed: invalid