Subject: | Incorrect line numbers in error messages |
The line numbers in the error messages reported by $js->eval ($script)
are one off. For example, here:
use warnings;
use strict;
use JavaScript::SpiderMonkey;
my $js1 =<<EOF;
;
1 = 3;
EOF
my $js = JavaScript::SpiderMonkey->new ();
$js->init ();
if (!$js->eval ($js1)) {
print "$@\n";
}
This produces
Error: SyntaxError: invalid assignment left-hand side at line 1: 1 = 3;
Notice the error line is given as "1".
The origin of this is in SpiderMonkey.pm:
sub eval {
##################################################
my ($self, $script) = @_;
return 1 unless defined $script;
my $ok =
JavaScript::SpiderMonkey::JS_EvaluateScript(
$self->{context},
$self->{global_object},
$script,
$] > 5.007 ? bytes::length($script) : length($script),
"Perl",
0);
return $ok;
}
The final function parameter of the call to JS_EvaluateScript is the
line number of the first line, and this should be 1, not 0.
This is also reported in the following bug report:
https://rt.cpan.org/Public/Bug/Display.html?id=29359