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

Parser not panicking in Grammar.pm #2394

Closed
p6rt opened this issue Mar 24, 2011 · 8 comments
Closed

Parser not panicking in Grammar.pm #2394

p6rt opened this issue Mar 24, 2011 · 8 comments

Comments

@p6rt
Copy link

p6rt commented Mar 24, 2011

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

Searchable as RT86906$

@p6rt
Copy link
Author

p6rt commented Mar 24, 2011

From tim.bollman@live.com

Location of Error​:
Grammar.pm line 2158 (as of ~5​:00 AM UTC on March 23)​:
if +@​parts != 2 {
  self.panic("Unable to find starter and stopper from '$opname'");
}

Short description of error​:
self.panic isn't... panicking.

Sample code​:

multi sub circumfix​:<⌊⌋>($a)
{
  return $a.floor;
}
(There's no need to actually call it, the definition is enough).

Long description​:
I was happily making a program that needed a floor operator. So I figured I would define a circumfix floor operator using the unicode symbols. But I didn't put a space between the two ends (having never created one before I was guessing on how to write it). Alas, I got "Null PMC access in get_integer" thrown in my face. Once I had traced it down to that space, I declared "ah! That's an easy enough thing to check for. Easy patch". A short grep later, I found the gen_op function in Grammar.pm and lo and behold, it was already checking for this error. I put in a debug say and it's getting to the check, so the logical conclusion is that the panic method isn't functioning like the developer expected (like perhaps it's not leaving the function).

Thanks,
-Tim

 

@p6rt
Copy link
Author

p6rt commented Mar 24, 2011

From @moritz

Am 24.03.2011 05​:00, schrieb Timothy Bollman (via RT)​:

Location of Error​:
Grammar.pm line 2158 (as of ~5​:00 AM UTC on March 23)​:
if +@​parts != 2 {
self.panic("Unable to find starter and stopper from '$opname'");
}

Short description of error​:
self.panic isn't... panicking.

Thanks for the report. I've committed a partial fix​:
rakudo/rakudo@792e860

I was happily making a program that needed a floor operator. So I
figured I would define a circumfix floor operator using the unicode
symbols. But I didn't put a space between the two ends (having never
created one before I was guessing on how to write it). Alas, I got
"Null PMC access in get_integer" thrown in my face. Once I had
traced it down to that space, I declared "ah! That's an easy enough
thing to check for. Easy patch". A short grep later, I found the
gen_op function in Grammar.pm and lo and behold, it was already checking
for this error. I put in a debug say and it's getting to the check,
so the logical conclusion is that the panic method isn't functioning
like the developer expected (like perhaps it's not leaving the function).

The problem with method gen_op is that it has a rather indirect call
chain, which seems to lose the context information. So when the .panic
call tries to include the current location, it gets a Null PMC instead
of the index into the string that is being parsed.

I don't understand the call mechanism sufficiently well to fix it, so
I've just added a pir​::die. So now you get the correct message, but no
file and line number.

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Mar 24, 2011

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

@p6rt
Copy link
Author

p6rt commented Jul 19, 2014

From @FROGGS

Current behaviour​:
FROGGS m​: multi sub circumfix​:<⌊⌋>($a) { return $a.floor; }
camelia rakudo-moar 866817​: OUTPUT«===SORRY!===␤Unable to find starter and stopper from '⌊⌋'␤»

File and line number would be great, aye.

@p6rt
Copy link
Author

p6rt commented Aug 5, 2014

From @perlpilot

On Sat Jul 19 12​:06​:39 2014, FROGGS.de wrote​:

Current behaviour​:
FROGGS m​: multi sub circumfix​:<⌊⌋>($a) { return $a.floor; }
camelia rakudo-moar 866817​: OUTPUT«===SORRY!===␤Unable to find starter
and stopper from '⌊⌋'␤»

File and line number would be great, aye.

See rakudo/rakudo@3852449

Now output looks like​:

➤ ./perl6-m foo
===SORRY!=== Error while compiling foo
Unable to identify both starter and stopper from '⌊⌋'
Perhaps you forgot to separate them with whitespace?
at foo​:9
------> multi sub circumfix​:<⌊⌋>⏏($a) { return $a.floor; }
  expecting any of​:
  colon pair
  quote words

-Scott

@p6rt
Copy link
Author

p6rt commented Dec 30, 2014

From @usev6

This fails now with a typed exception "X​::Syntax​::AddCategorial​::MissingSeparator" (commit rakudo/rakudo@e9ea2dc0c5).

I added a test to S06-operator-overloading/sub.t with commit Raku/roast@d84f6bcbb3

I'm closing this ticket -- please reopen if there is something missing.

1 similar comment
@p6rt
Copy link
Author

p6rt commented Dec 30, 2014

From @usev6

This fails now with a typed exception "X​::Syntax​::AddCategorial​::MissingSeparator" (commit rakudo/rakudo@e9ea2dc0c5).

I added a test to S06-operator-overloading/sub.t with commit Raku/roast@d84f6bcbb3

I'm closing this ticket -- please reopen if there is something missing.

@p6rt
Copy link
Author

p6rt commented Dec 30, 2014

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

@p6rt p6rt closed this as completed Dec 30, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant