Skip Menu |

Subject: [LTA] Only a line number is printed when assigning to immutable values (stuff; $x = 42; stuff)
Download (untitled) / with headers
text/plain 235b
Code: my $x := 42; my $a = 4 + 8; $x = 24; my $b = 15 + 16; Result: Cannot assign to an immutable value in block <unit> at foo.p6 line 2 Line 2, right, but where exactly? Surely it can also print the cursor position or something.
Download (untitled) / with headers
text/plain 411b
Right. After thinking about it, I now realize that almost any run-time error is giving such LTA error message. Perhaps instead of storing just the line number it should store something else, maybe the global position in the file or something. So that it can give an error with up to semicolon precision, not just the line number. Maybe the title of this bug report should be changed to something more general.
To: "Alex Jakimenko (via RT)" <perl6-bugs-followup [...] perl.org>
Subject: Re: [perl #128402] [LTA] Only a line number is printed when assigning to immutable values (stuff; $x = 42; stuff)
From: Elizabeth Mattijsen <liz [...] dijkmat.nl>
Date: Wed, 15 Jun 2016 06:32:08 +0200
Download (untitled) / with headers
text/plain 828b
Show quoted text
> On 15 Jun 2016, at 00:38, Alex Jakimenko (via RT) <perl6-bugs-followup@perl.org> wrote: > > # New Ticket Created by Alex Jakimenko > # Please include the string: [perl #128402] > # in the subject line of all future correspondence about this issue. > # <URL: https://rt.perl.org/Ticket/Display.html?id=128402 > > > > Code: > my $x := 42; > my $a = 4 + 8; $x = 24; my $b = 15 + 16; > > > Result: > Cannot assign to an immutable value > in block <unit> at foo.p6 line 2 > > > Line 2, right, but where exactly? Surely it can also print the cursor position or something.
We don’t have the $/.CURSOR around at runtime. So in order to show where it happened in the line, one would have to also put that info in the opcodes. That feels like bloat to me. Workaround: put the assignments on different lines :-) Liz
To: Elizabeth Mattijsen <liz [...] dijkmat.nl>
CC: "Alex Jakimenko (via RT)" <perl6-bugs-followup [...] perl.org>
Subject: Re: [perl #128402] [LTA] Only a line number is printed when assigning to immutable values (stuff; $x = 42; stuff)
From: Parrot Raiser <1parrota [...] gmail.com>
Date: Wed, 15 Jun 2016 19:23:34 -0400
Download (untitled) / with headers
text/plain 995b
I concur. The language shouldn't bend over backwards to accommodate bad habits. On 6/15/16, Elizabeth Mattijsen <liz@dijkmat.nl> wrote: Show quoted text
>> On 15 Jun 2016, at 00:38, Alex Jakimenko (via RT) >> <perl6-bugs-followup@perl.org> wrote: >> >> # New Ticket Created by Alex Jakimenko >> # Please include the string: [perl #128402] >> # in the subject line of all future correspondence about this issue. >> # <URL: https://rt.perl.org/Ticket/Display.html?id=128402 > >> >> >> Code: >> my $x := 42; >> my $a = 4 + 8; $x = 24; my $b = 15 + 16; >> >> >> Result: >> Cannot assign to an immutable value >> in block <unit> at foo.p6 line 2 >> >> >> Line 2, right, but where exactly? Surely it can also print the cursor >> position or something.
> > We don’t have the $/.CURSOR around at runtime. So in order to show where it > happened in the line, one would have to also put that info in the opcodes. > That feels like bloat to me. > > Workaround: put the assignments on different lines :-) > > > Liz
Download (untitled) / with headers
text/plain 1.5k
On Wed Jun 15 16:24:04 2016, 1parrota@gmail.com wrote: Show quoted text
> I concur. The language shouldn't bend over backwards to accommodate > bad habits. > > On 6/15/16, Elizabeth Mattijsen <liz@dijkmat.nl> wrote:
> >> On 15 Jun 2016, at 00:38, Alex Jakimenko (via RT) > >> <perl6-bugs-followup@perl.org> wrote: > >> > >> # New Ticket Created by Alex Jakimenko > >> # Please include the string: [perl #128402] > >> # in the subject line of all future correspondence about this issue. > >> # <URL: https://rt.perl.org/Ticket/Display.html?id=128402 > > >> > >> > >> Code: > >> my $x := 42; > >> my $a = 4 + 8; $x = 24; my $b = 15 + 16; > >> > >> > >> Result: > >> Cannot assign to an immutable value > >> in block <unit> at foo.p6 line 2 > >> > >> > >> Line 2, right, but where exactly? Surely it can also print the > >> cursor > >> position or something.
> > > > We don’t have the $/.CURSOR around at runtime. So in order to show > > where it > > happened in the line, one would have to also put that info in the > > opcodes. > > That feels like bloat to me. > > > > Workaround: put the assignments on different lines :-) > > > > > > Liz
Bad habits like what? Using a one liner in your command line? Or using camelia on IRC? Sure, you can avoid it, but it does not make the error message any more awesome. As for the implementation, I don't know. It would be sad if there's no easy way to fix it. But at the same time I'm not sure why it is possible to hold the line number without any problems but having some additional information (maybe even stored in the same int) is such a big problem.
RT-Send-CC: 1parrota [...] gmail.com, liz [...] dijkmat.nl, jnthn [...] jnthn.net
Download (untitled) / with headers
text/plain 698b
Well we would have to annotate MAST and JAST nodes with the column information in addition to the line number. The column is surprisingly easy to get by replacing: my $line := HLL::Compiler.lineof($node.orig(), $node.from(), :cache(1)); with: my $line_col := HLL::Compiler.line_and_column_of($node.orig(), $node.from(), :cache(1)); my $line := nqp::atpos_i($line_col, 0); my $column := nqp::atpos_i($line_col, 1); lineof actually calls line_and_column_of and just discards the column data. So the cost is one annotate per node and a couple of minutes of coding time. Benchmarks would show if it's worth it. Or maybe jnthn can shoot it down even earlier by telling is that this would cost a lot ;)


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org