Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The curious case of the one-off line number in Rakudo #1795

Closed
p6rt opened this issue May 30, 2010 · 5 comments
Closed

The curious case of the one-off line number in Rakudo #1795

p6rt opened this issue May 30, 2010 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented May 30, 2010

Migrated from rt.perl.org#75446 (status was 'resolved')

Searchable as RT75446$

@p6rt
Copy link
Author

p6rt commented May 30, 2010

From @masak

<masak> I've found a case where a line number is one-off. should I nopaste it?
<jnthn> masak​: please
<masak> I don't think it's the fault of the new backtraces thing, to be honest.
<masak> more like a result of parsing or something.
<jnthn> Well, the other thing is that we don't have as many :node($/)s
in Actions.pm as we maybe should.
<jnthn> So could very well be some wins to be had by some careful
extra scattering of those.
<masak> http://gist.github.com/418990

(inlined here)

$ cat one-off
sub bar {
  pfff
}

bar

$ perl6 one-off
Could not find sub &pfff
in 'bar' at line 1​:one-off
in main program body at line 6​:one-off

<jnthn> masak​: curious
<jnthn> masak​: Does it get it right if you do pfff() ?
<jnthn> as in, add parens?
* masak tries
* jnthn had a test very much like that which got it right
<masak> no.
<jnthn> ok
<masak> maybe it sees the statement as starting on line 1, or something?
<jnthn> That's very possible.
<jnthn> I just thought that it'd been getting it right.
<jnthn> (I had a very similar test case...)
* jnthn plays spot the difference
<jnthn> masak​: hmm, I agree it seems to be one off there.
* masak submits rakudobug
<jnthn> masak​: Think it may be a Parrot fix.
<jnthn> masak​: Thing is, the annotations in the PIR look correct.
<jnthn> Trying my first guess at a patch now.
<masak> I'll include that in the Rakudobug. :)

@p6rt
Copy link
Author

p6rt commented Jun 5, 2010

From @jnthn

On Sun May 30 05​:44​:14 2010, masak wrote​:

<masak> I've found a case where a line number is one-off. should I
nopaste it?
<jnthn> masak​: please
<masak> I don't think it's the fault of the new backtraces thing, to
be honest.
<masak> more like a result of parsing or something.
<jnthn> Well, the other thing is that we don't have as many :node($/)s
in Actions.pm as we maybe should.
<jnthn> So could very well be some wins to be had by some careful
extra scattering of those.
<masak> http://gist.github.com/418990

(inlined here)

$ cat one-off
sub bar {
pfff
}

bar

$ perl6 one-off
Could not find sub &pfff
in 'bar' at line 1​:one-off
in main program body at line 6​:one-off

<jnthn> masak​: curious
<jnthn> masak​: Does it get it right if you do pfff() ?
<jnthn> as in, add parens?
* masak tries
* jnthn had a test very much like that which got it right
<masak> no.
<jnthn> ok
<masak> maybe it sees the statement as starting on line 1, or
something?
<jnthn> That's very possible.
<jnthn> I just thought that it'd been getting it right.
<jnthn> (I had a very similar test case...)
* jnthn plays spot the difference
<jnthn> masak​: hmm, I agree it seems to be one off there.
* masak submits rakudobug
<jnthn> masak​: Think it may be a Parrot fix.
<jnthn> masak​: Thing is, the annotations in the PIR look correct.
<jnthn> Trying my first guess at a patch now.
<masak> I'll include that in the Rakudobug. :)

We needed a Parrot tweak which I did a couple of days back - but that
only got us off by one in the *other* direction because it emitted the
right annotation, but we were emitting the wrong line number in it.
Grrr. Anyway, today I nailed it with a little tweak in Rakudo, so now​:

C​:\Consulting\rakudo>type test.p6
sub bar {
pfff
}

bar

C​:\Consulting\rakudo>perl6 test.p6
Could not find sub &pfff
  in 'bar' at line 2​:test.p6
  in main program body at line 5​:test.p6

Which is spot on. \o/

Given to moritz++ for testing.

Thanks,

Jonathan

@p6rt
Copy link
Author

p6rt commented Jun 5, 2010

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jun 5, 2010

@moritz - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Jun 5, 2010
@p6rt
Copy link
Author

p6rt commented Jun 5, 2010

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/integration/error-reporting.t

commit cc81e350331b3b471eb2b9a6c79f1959406b8619
Author​: moritz <moritz@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Sat Jun 5 21​:22​:15 2010 +0000

  [t/spec] test for RT #​75446, offby1 line number report for non-existing sub calls
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;31134 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/integration/error-reporting.t b/t/spec/integration/error-reporting.t
index b3fc71f..1167dfc 100644
--- a/t/spec/integration/error-reporting.t
+++ b/t/spec/integration/error-reporting.t
@@ -1,7 +1,7 @@
 use v6;
 use Test;
 
-plan 3;
+plan 4;
 
 BEGIN { @*INC.push('t/spec/packages') };
 
@@ -23,5 +23,18 @@ is_run "use v6;\n\nsay 'Hello';\nsay 'a'.my_non_existent_method_6R5();",
     {
         status  => { $_ != 0 },
         out     => /Hello\r?\n/,
-        err     => all(rx/my_non_existent_method_6R5/ & rx/:i 'line 4'/),
+        err     => all(rx/my_non_existent_method_6R5/, rx/:i 'line 4'/),
     }, 'Method not found error mentions method name and line number';
+
+# RT #75446
+is_run 'use v6;
+sub bar {
+    pfff();
+}
+
+bar()',
+    {
+        status => { $_ != 0 },
+        out     => '',
+        err     => all(rx/pfff/, rx/'line 3'>>/),
+    }, 'got the right line number for nonexisting sub inside another sub';

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant