One day, we might want to get a proper backtrace, but in the meantime
it is easier to avoid wrapping a single error in several layers of
line number info, which are often wrong, as we do not clear the position
stack in error paths.
my $current_file_name;
my $current_string;
my $current_pos;
+my $reported_error;
sub error($;$) {
my ($msg, $offset) = @_;
- if (defined $current_file_name) {
+ if (defined $current_file_name && !$reported_error) {
#
# This is rather tricky. We want to report the exact place, where the error
# occurred, but the cost of keeping track of the current line number is too high.
my $input = substr(${$current_string}, 0, $current_pos);
my @newlines = ($input =~ m{\n}g);
my $line = @newlines + ($offset // 1);
+ $reported_error++;
die "$current_file_name:$line: $msg\n";
} else {
die "$msg\n";
sub start(;$) {
$arguments = $_[0];
@cond = (1);
+ $reported_error = 0;
}
sub finish() {