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

Grammar parse failure should probably return Nil not Any #4727

Closed
p6rt opened this issue Nov 3, 2015 · 9 comments
Closed

Grammar parse failure should probably return Nil not Any #4727

p6rt opened this issue Nov 3, 2015 · 9 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Nov 3, 2015

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

Searchable as RT126558$

@p6rt
Copy link
Author

p6rt commented Nov 3, 2015

From @ronaldxs

According to the docs​:
http://docs.perl6.org/type/Grammar#method_parse
"Method parse ... Returns a Match object on success, and Nil on failure."

18​:07 mr_ron m​: grammar G { token TOP { a+ } }; my Nil $x = G.parse("zz")
18​:07 camelia rakudo-moar 273e89​: OUTPUT«Type check failed in assignment to $x; expected Nil but got Any␤ in block <unit> at /tmp/HMNfyPJjvI​:1␤␤»

17​:56 mr_ron m​: grammar G { token TOP { a+ | <bs> }; token bs { b+ } }; say G.parse("zz").WHAT; say G.parse("aa")<bs>.WHAT
17​:56 camelia rakudo-moar 273e89​: OUTPUT«(Any)␤Nil␤»

Then
http://irclog.perlgeek.de/perl6/2015-11-03#i_11477014

@p6rt
Copy link
Author

p6rt commented Nov 3, 2015

From @ronaldxs

According to the docs​:
http://docs.perl6.org/type/Grammar#method_parse
"Method parse ... Returns a Match object on success, and Nil on failure."

18​:07 mr_ron m​: grammar G { token TOP { a+ } }; my Nil $x = G.parse("zz")
18​:07 camelia rakudo-moar 273e89​: OUTPUT«Type check failed in assignment to $x; expected Nil but got Any␤ in block <unit> at /tmp/HMNfyPJjvI​:1␤␤»

17​:56 mr_ron m​: grammar G { token TOP { a+ | <bs> }; token bs { b+ } }; say G.parse("zz").WHAT; say G.parse("aa")<bs>.WHAT
17​:56 camelia rakudo-moar 273e89​: OUTPUT«(Any)␤Nil␤»

Then http://irclog.perlgeek.de/perl6/2015-11-03#i_11477014

@p6rt
Copy link
Author

p6rt commented Dec 19, 2016

From @ronaldxs

On Tue, 03 Nov 2015 14​:26​:06 -0800, ronaldxs wrote​:

18​:07 mr_ron m​: grammar G { token TOP { a+ } }; my Nil $x =
G.parse("zz")
18​:07 camelia rakudo-moar 273e89​: OUTPUT«Type check failed in
assignment to $x; expected Nil but got Any␤ in block <unit> at
/tmp/HMNfyPJjvI​:1␤␤»

17​:56 mr_ron m​: grammar G { token TOP { a+ | <bs> }; token bs { b+ }
}; say G.parse("zz").WHAT; say G.parse("aa")<bs>.WHAT
17​:56 camelia rakudo-moar 273e89​: OUTPUT«(Any)␤Nil␤»

Reran test cases and they now run as expected. Might be of interest to add test case(s?) to roast/S05-match/non-capturing.t?

@p6rt
Copy link
Author

p6rt commented Dec 19, 2016

@ronaldxs - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Aug 21, 2017

From @AlexDaniel

Is this ticket relevant today?

Note that we also have this​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=131919
On 2016-12-19 08​:41​:33, ronaldxs wrote​:

On Tue, 03 Nov 2015 14​:26​:06 -0800, ronaldxs wrote​:

18​:07 mr_ron m​: grammar G { token TOP { a+ } }; my Nil $x =
G.parse("zz")
18​:07 camelia rakudo-moar 273e89​: OUTPUT«Type check failed in
assignment to $x; expected Nil but got Any␤ in block <unit> at
/tmp/HMNfyPJjvI​:1␤␤»

17​:56 mr_ron m​: grammar G { token TOP { a+ | <bs> }; token bs { b+ }
}; say G.parse("zz").WHAT; say G.parse("aa")<bs>.WHAT
17​:56 camelia rakudo-moar 273e89​: OUTPUT«(Any)␤Nil␤»

Reran test cases and they now run as expected. Might be of interest
to add test case(s?) to roast/S05-match/non-capturing.t?

@p6rt
Copy link
Author

p6rt commented Aug 21, 2017

From @ronaldxs

Hopefully it's just a doc issue but​:

https://docs.perl6.org/routine/parse

still says​:

Returns a Match object on success, and Nil on failure.

@p6rt
Copy link
Author

p6rt commented Aug 21, 2017

From @ronaldxs

Noticed that RT #​131919 is new and may apply to 6.d and would like to take a few days to review further.

@p6rt
Copy link
Author

p6rt commented Aug 28, 2017

From @ronaldxs

Request for test cases now roast issue​: Raku/roast#297

Planning to close this ticket soon if no objection.

@p6rt
Copy link
Author

p6rt commented Aug 29, 2017

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

@p6rt p6rt closed this as completed Aug 29, 2017
@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