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

Infinite recursion when using Match object as hash key #1855

Closed
p6rt opened this issue Jun 18, 2010 · 7 comments
Closed

Infinite recursion when using Match object as hash key #1855

p6rt opened this issue Jun 18, 2010 · 7 comments

Comments

@p6rt
Copy link

p6rt commented Jun 18, 2010

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

Searchable as RT75868$

@p6rt
Copy link
Author

p6rt commented Jun 18, 2010

From @moritz

./perl6 -e 'my %h = a => 1; "a" ~~ /./; say %h{$/}'
maximum recursion depth exceeded
  in 'postcircumfix​:<{ }>' at line 1
  in 'postcircumfix​:<{ }>' at line 1
  in 'postcircumfix​:<{ }>' at line 1
  in 'postcircumfix​:<{ }>' at line 1
  in 'postcircumfix​:<{ }>' at line 1
...

@p6rt
Copy link
Author

p6rt commented Sep 6, 2010

From @gfldex

my %h;
grammar Foo {
  rule TOP { <bar>+ };
  token bar {
  (.)
  { %h{$0} = 1 } # <-- Recursion limit hit here. $0 should
be $0.Str but rakudo takes it as Match and fails horribly. :(
  }
};

Foo.parse('abc');
say %h.perl;

--

rakudo ae66fe​: OUTPUT<<maximum recursion depth exceededNL in
'Any​::postcircumfix​:<{ }>' at line 1NL in <anon> at line 1NL in
  'Any​::postcircumfix​:<{ }>' at line 1NL in <anon> at line
1NL in 'Any​::postcircumfix​:<{ }>' at line 1NL in <anon> at line 1NL in
  'Any​::postcircumfix​:<{ }>' at line 1NL in

@p6rt
Copy link
Author

p6rt commented Sep 7, 2010

From @pmichaud

I've added a workaround for now that causes Match objects to act sanely
when used as subscripts, but a more solid fix will require some spec
clarifications.

Assigning ticket to moritz for spectest coverage; when we have spectests
for this I'm happy with closing the ticket for now.

Pm

@p6rt
Copy link
Author

p6rt commented Sep 7, 2010

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

@p6rt
Copy link
Author

p6rt commented Sep 18, 2010

From @moritz

now tested in S02-builtin_data_types/hash.t

@p6rt
Copy link
Author

p6rt commented Sep 18, 2010

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

@p6rt p6rt closed this as completed Sep 18, 2010
@p6rt
Copy link
Author

p6rt commented Sep 18, 2010

From @kyleha

This is an automatically generated mail to inform you that tests are now available in S02-builtin_data_types/hash.t

commit 8c3cfd3736de11047d6041384bfa9c8e043c7533
Author​: Moritz Lenz <moritz@​faui2k3.org>
Date​: Sat Sep 18 19​:41​:25 2010 +0200

  test for RT #​75868, Match objects as Hash keys

Inline Patch
diff --git a/S02-builtin_data_types/hash.t b/S02-builtin_data_types/hash.t
index 52fc7dd..54400df 100644
--- a/S02-builtin_data_types/hash.t
+++ b/S02-builtin_data_types/hash.t
@@ -2,7 +2,7 @@ use v6;
 
 use Test;
 
-plan 74;
+plan 76;
 
 # basic lvalue assignment
 # L<S09/Hashes>
@@ -250,6 +250,15 @@ lives_ok { Hash.new("a" => "b") }, 'Hash.new($pair) lives';
     is %h{*}.join('|'), %h.values.join('|'), '{*} zen slice';
 }
 
+# RT #75868
+{
+    my %h = (ab => 'x', 'a' => 'y');
+    'abc' ~~ /^(.)./;
+    is %h{$/}, 'x', 'can use $/ as hash key';
+    is %h{$0}, 'y', 'can use $0 as hash key';
+
+}
+
 done_testing;
 
 # vim: ft=perl6

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