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

Cannot do .keys on enum type stash in Rakudo #1418

Closed
p6rt opened this issue Nov 27, 2009 · 7 comments
Closed

Cannot do .keys on enum type stash in Rakudo #1418

p6rt opened this issue Nov 27, 2009 · 7 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Nov 27, 2009

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

Searchable as RT70894$

@p6rt
Copy link
Author

p6rt commented Nov 27, 2009

From @masak

<masak> TimToady​: how do I get all the names the elements of an enum, in order?
<masak> TimToady​: simplest one I've found so far is SomeEnum.pick(*).sort
<masak> hardly very idiomatic.
<TimToady> masak​: you might try SomeEnum​::.keys since Type​:: is
supposed to be the stash of the type; no guarantees about rakudo
though
<masak> TimToady​: oki, thanks.
<TimToady> doesn't guarantee order either
<TimToady> though of course, enums are only conventionally in a particular order
<TimToady> they're just a convenient way to write a lot of constants

<masak> rakudo​: enum SomeEnum <a b c>; say SomeEnum​::.keys
<masak> locally, I get "invoke() not implemented in class 'Perl6Role'"
<p6eval> rakudo 7347ec​: ( no output )
<masak> is that worth a rakudobug submission?
<masak> std​: enum SomeEnum <a b c>; say SomeEnum​::.keys
<p6eval> std 29203​: ok 00​:01 106m␤
* jnthn looks confused at what the intent was there
<jnthn> Oh
<jnthn> Treating it as a namespace...hm
<masak> yah. a stash, said TimToady.
* jnthn is vaguely surprised Rakudo even parses that.
<masak> heh.
<jnthn> I guess if it ends with :​: we're meant to treat it as a
stash...I guess I can go with that.
<jnthn> File rakudobug if you like.
* masak likes

@p6rt
Copy link
Author

p6rt commented Jun 27, 2010

From radu_cs85@yahoo.com

Added test for this in t/spec/S02-builtin_data_types/enum.t .

@p6rt
Copy link
Author

p6rt commented Jun 27, 2010

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

@p6rt
Copy link
Author

p6rt commented Jun 27, 2010

From @kyleha

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

commit ec3fecca07d477e483f061520a4765587652383d
Author​: radus <radus@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Sun Jun 27 08​:30​:51 2010 +0000

  [t/spec] Added test for RT70894​: Cannot do .keys on enum type stash in Rakudo.
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;31474 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/S02-builtin_data_types/enum.t b/t/spec/S02-builtin_data_types/enum.t
index 6c573b2..0eddf9f 100644
--- a/t/spec/S02-builtin_data_types/enum.t
+++ b/t/spec/S02-builtin_data_types/enum.t
@@ -83,7 +83,8 @@ is %hash.values.sort, <A B C D E>, '...and the right values are assigned';
 
 %hash = ();
 
-lives_ok { %hash = enum <<:Alpha<A> Bravo Charlie Delta Echo>>; }, 'specifying a string up front works (Texas quotes)', :todo<feature>;
+#?rakudo todo 'feature'
+lives_ok { %hash = enum <<:Alpha<A> Bravo Charlie Delta Echo>>; }, 'specifying a string up front works (Texas quotes)'; 
 
 #?pugs todo 'feature'
 is %hash.keys.sort, <Alpha Bravo Charlie Delta Echo>, '...and the right keys are assigned';
@@ -133,6 +134,15 @@ is %hash.values, (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'A', 'B', 'C', 'D', 'E', 'F'), '
     dies_ok { RT66648.c }, 'die attempting to access enum item as method';
 }
 
+# RT #70894
+
+{
+    enum SomeEnum <a b c>;
+    #?rakudo skip "RT #70894"
+    lives_ok {SomeEnum::.keys}, 'keys on enum stash works';
+
+}
+
 done_testing;
 
 # vim: ft=perl6

@p6rt
Copy link
Author

p6rt commented Sep 11, 2011

From @bbkr

NOM​: does not die, however output looks wrong

bbkr​:nom bbkr$ ./perl6 -e 'enum SomeEnum <a b c>; say SomeEnum​::.keys'
0

@p6rt
Copy link
Author

p6rt commented Sep 20, 2011

From @moritz

On Sun Sep 11 13​:33​:55 2011, bbkr wrote​:

NOM​: does not die, however output looks wrong

bbkr​:nom bbkr$ ./perl6 -e 'enum SomeEnum <a b c>; say SomeEnum​::.keys'
0

The output is right, in fact.

The spec has changed, and the enum keys can be found with
SomeEnum.enums.keys, which works fine. without the .enums, .keys falls
back to Any.keys, which is 0 for a scalar.

I'll unfudge the test in t/spec/S02-types/enum.t and consider this
ticket closed.

@p6rt
Copy link
Author

p6rt commented Sep 20, 2011

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

@p6rt p6rt closed this as completed Sep 20, 2011
@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