Here's an example.
#line 15
my $hash = {
over => 'under',
left => 'right',
key => func() {
return __LINE__;
},
foo => "bar",
up => "down",
};
is $hash->{key}->(), 19;
is __LINE__, 26;
It doesn't matter how many hash pairs come before the function, it will always return 16. The function thinks it starts on the same line as the hash.
This has been a problem since at least v20090424. This does not appear to be a mistake on our part, but something wrong with the compiler / Devel::Declare.
This a particular problem in classes which use Moose.
has foo =>
is => 'rw',
default => method() {
return $self->bar + 23;
};