Once a .tg file is compiled to a .pir file, any errors in the
embedded PIR are reported against the line number
of the generated PIR file.
Instead, the line numbers should be reported against the original .tg
file.
--
Will "Coke" Coleda
wi...@coleda.com
Is there an imcc pragma for setting the line number to be reported
for an error? Or what's the general approach to getting the generated
PIR file to report the correct line number?
Pm
=head2 How do I embed source locations in my code for debugging?
You can do this using either the C<setfile> and C<setline> opcodes or
with C-like C<#line> comments:
#line 27 "my_source.file"
Simply set the source file name or line number whenever it changes.
But note that currently (Parrot 0.3.0) both are ignored in the lexer.
--
Will "Coke" Coleda
wi...@coleda.com
Kudos to Jonathan for implementing RT#40806, which enabled the
#line <nnn> "file" directive needed for this to work.
TGE now reports errors relative to the original .tg file. Thus
error:imcc:The opcode 'say_ic' (say<1>) was not found. Check the type
and number of the arguments
in file 'src/PASTGrammar.tg' line 124
instead of
error:imcc:The opcode 'say_ic' (say<1>) was not found. Check the type
and number of the arguments
in file 'src/PASTGrammar_gen.pir' line 152
I'll note that the line number reported is off-by-one from where it
actually occurs in the file, but that's because Parrot reports PIR
errors as off-by-one, not because of this patch. (When Parrot reports
the correct line number, this will work here also.)
Marking this ticket as "resolved".
Pm