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

Rakudo fails to give "Null regex not allowed" for a number of operators #2155

Closed
p6rt opened this issue Sep 11, 2010 · 9 comments
Closed

Rakudo fails to give "Null regex not allowed" for a number of operators #2155

p6rt opened this issue Sep 11, 2010 · 9 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Sep 11, 2010

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

Searchable as RT77784$

@p6rt
Copy link
Author

p6rt commented Mar 31, 2010

From @masak

<masak> std​: "abc" ~~ /()/
<p6eval> std 30251​: OUTPUT«�[31m===�[0mSORRY!�[31m===�[0m␤Null pattern
not allowed [...] FAILED 00​:01 107m␤»
<masak> rakudo​: "abc" ~~ /()/
<p6eval> rakudo 872898​: OUTPUT«Confused [...]
* masak submits LTA rakudobug
<masak> rakudo​: "abc" ~~ /[]/
<p6eval> rakudo 872898​: OUTPUT«Confused [...]

This all comes down to how nqp-rx parses regexes. It can do it
slightly more informatively in the case of empty () and [].

@p6rt
Copy link
Author

p6rt commented Sep 11, 2010

From @masak

<moritz_> std​: / /
<p6eval> std 32123​: OUTPUT«�[31m===�[0mSORRY!�[31m===�[0m␤Null regex
not allowed [...] FAILED 00​:01 114m␤»
<moritz_> rakudo​: / /
<p6eval> rakudo ce565f​: OUTPUT«===SORRY!===␤Null regex not allowed [...]
<moritz_> rakudo​: / & /
<p6eval> rakudo ce565f​: ( no output )
<moritz_> bug
<moritz_> rakudo​: / | /
<p6eval> rakudo ce565f​: ( no output )
<moritz_> same bug
<masak> std​: / & /
<p6eval> std 32123​: OUTPUT«�[31m===�[0mSORRY!�[31m===�[0m␤Null pattern
not allowed [...] FAILED 00​:02 115m␤»

In the '|' case, it's OK for the left side to be empty, but there
should be an error for the right side being empty.

@p6rt
Copy link
Author

p6rt commented Feb 13, 2012

From @coke

On Wed Mar 31 15​:45​:50 2010, masak wrote​:

<masak> std​: "abc" ~~ /()/
<p6eval> std 30251​: OUTPUT«�[31m===�[0mSORRY!�[31m===�[0m␤Null pattern
not allowed [...] FAILED 00​:01 107m␤»
<masak> rakudo​: "abc" ~~ /()/
<p6eval> rakudo 872898​: OUTPUT«Confused [...]
* masak submits LTA rakudobug
<masak> rakudo​: "abc" ~~ /[]/
<p6eval> rakudo 872898​: OUTPUT«Confused [...]

This all comes down to how nqp-rx parses regexes. It can do it
slightly more informatively in the case of empty () and [].

Error message has changed​:

22​:00 < [Coke]> rakudo​: "abc" ~~ /()/
22​:00 <+p6eval> rakudo 29f5cf​: OUTPUT«===SORRY!===␤Unrecognized regex
  metacharacter (must be quoted to match literally) at line 1,
  near "/"␤»
22​:00 < [Coke]> rakudo​: "abc" ~~ /[]/
22​:00 <+p6eval> rakudo 29f5cf​: OUTPUT«===SORRY!===␤Unrecognized regex
  metacharacter (must be quoted to match literally) at line 1,
  near "/"␤»

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Feb 13, 2012

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

@p6rt
Copy link
Author

p6rt commented May 29, 2012

From @diakopter

On Sun Feb 12 19​:01​:21 2012, coke wrote​:

On Wed Mar 31 15​:45​:50 2010, masak wrote​:

<masak> std​: "abc" ~~ /()/
<p6eval> std 30251​: OUTPUT«�[31m===�[0mSORRY!�[31m===�[0m␤Null
pattern
not allowed [...] FAILED 00​:01 107m␤»
<masak> rakudo​: "abc" ~~ /()/
<p6eval> rakudo 872898​: OUTPUT«Confused [...]
* masak submits LTA rakudobug
<masak> rakudo​: "abc" ~~ /[]/
<p6eval> rakudo 872898​: OUTPUT«Confused [...]

This all comes down to how nqp-rx parses regexes. It can do it
slightly more informatively in the case of empty () and [].

Error message has changed​:

22​:00 < [Coke]> rakudo​: "abc" ~~ /()/
22​:00 <+p6eval> rakudo 29f5cf​: OUTPUT«===SORRY!===␤Unrecognized regex
metacharacter (must be quoted to match literally) at
line 1,
near "/"␤»
22​:00 < [Coke]> rakudo​: "abc" ~~ /[]/
22​:00 <+p6eval> rakudo 29f5cf​: OUTPUT«===SORRY!===␤Unrecognized regex
metacharacter (must be quoted to match literally) at
line 1,
near "/"␤»

This has a couple later submitted duplicates.

@p6rt
Copy link
Author

p6rt commented Jan 15, 2014

From @moritz

< moritz> p​: /a | /
<+camelia> rakudo-parrot 4f66ce​: OUTPUT«===SORRY!===␤Unrecognized regex
metacharacter | (must be quoted to match literally)␤at
/tmp/zXzH2EnbDL​:1␤------> /a | ⏏/␤Unable to parse regex; couldn't find
final '/'␤at /tmp/zXzH2EnbDL​:1␤------> /…»

This should be reported as null pattern instead​:

< moritz> std​: /a | /
<+camelia> std 09dda5b​: OUTPUT«===SORRY!===␤Null pattern not allowed at
  /tmp/bw6vpvA5Z0 line 1​:␤------> /a | ⏏/␤Parse failed␤FAILED 00​:01 122m␤»

I have already added tests for that​:

commit 73208bff83283e4eb1b994bfcd5ef6fd885a00ec
Author​: Moritz Lenz <mlenz@​noris.net>
Date​: Wed Jan 15 10​:58​:54 2014 +0100

  RT #​78404​: Error reporting on Null regexes

Inline Patch
diff --git a/S32-exceptions/misc.t b/S32-exceptions/misc.t
index 0d4b9ed..d361f9c 100644
--- a/S32-exceptions/misc.t
+++ b/S32-exceptions/misc.t
@@ -133,6 +133,17 @@ throws_like 'my role R { has $.x; has $.y }; 99 
does R("wrong");', X::R   \# RT #​73806   throws\_like q\[if\(\) \{\}\], X​::Comp​::Group, sorrows => sub \(@​s\) \{ @​s\[0\] ~~ X​::Syntax​::KeywordAs

+# RT #​78404
+throws_like q[my grammar G { regex foo { } }], X​::Syntax​::Regex​::NullRegex;
+throws_like q[/ /], X​::Syntax​::Regex​::NullRegex;
+# just an empty branch, still same error, please
+#?rakudo skip "LTA error"
+throws_like q[/ a | /], X​::Syntax​::Regex​::NullRegex;
+#?rakudo skip "LTA error"
+throws_like q[/ a || /], X​::Syntax​::Regex​::NullRegex;
+#?rakudo skip "LTA error"
+throws_like q[/ a & /], X​::Syntax​::Regex​::NullRegex;
+

  throws_like 'sub f($a?, $b) { }', X​::Parameter​::WrongOrder,
  misplaced => 'required',

@p6rt
Copy link
Author

p6rt commented Apr 14, 2014

From @Mouq

This has been fixed and the tests pass. Marking as resolved.

@p6rt
Copy link
Author

p6rt commented Apr 14, 2014

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

@p6rt
Copy link
Author

p6rt commented Apr 14, 2014

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

@p6rt p6rt closed this as completed Apr 14, 2014
@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