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 instantiate subtype of Array or Hash in Rakudo #1159

Closed
p6rt opened this issue Jul 23, 2009 · 6 comments
Closed

Cannot instantiate subtype of Array or Hash in Rakudo #1159

p6rt opened this issue Jul 23, 2009 · 6 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jul 23, 2009

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

Searchable as RT67818$

@p6rt
Copy link
Author

p6rt commented Jul 23, 2009

From @masak

<masak> rakudo​: subset Person of Hash where { .keys.sort ~~ <firstname
lastname> }; my Person $p = { :firstname<Kyle>, :lastname<Ha> }
<p6eval> rakudo f5ccc0​: OUTPUT«Could not build C3 linearization​:
ambiguous hierarchy␤in sub trait_mod​:of [...]
<masak> I think I just found a bug. \o/
<masak> jnthn​: seen something like this before?
<jnthn> not seen that one before... :-S
<jnthn> report
<masak> rakudo​: subset Person of Hash; my Person $p = {}
<p6eval> rakudo f5ccc0​: OUTPUT«Could not build C3 linearization​:
ambiguous hierarchy␤in sub trait_mod​:of [...]
* masak reports
<masak> rakudo​: subset Austria of Array; my Austria $p = []
<p6eval> rakudo f5ccc0​: OUTPUT«Could not build C3 linearization​:
ambiguous hierarchy␤in sub trait_mod​:of [...]
<masak> rakudo​: subset Meercat of Pair; my Meercat $p = :a<b>
<p6eval> rakudo f5ccc0​: ( no output )
<masak> rakudo​: subset Austria of List; my Austria $p = []
<p6eval> rakudo f5ccc0​: ( no output )

So subtyping Pair and List works, but not subtyping Array or Hash.

@p6rt
Copy link
Author

p6rt commented Jul 26, 2009

From @kyleha

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

commit 82ad44091d9fa6f760c7b464384436a4102b4c2f
Author​: kyle <kyle@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Sun Jul 26 02​:27​:20 2009 +0000

  [t/spec] Test for RT #​67818
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;27742 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/S02-polymorphic_types/subset.t b/t/spec/S02-polymorphic_types/subset.t
index caa84b1..e92b573 100644
--- a/t/spec/S02-polymorphic_types/subset.t
+++ b/t/spec/S02-polymorphic_types/subset.t
@@ -1,6 +1,6 @@
 use v6;
 use Test;
-plan 10;
+plan 15;
 
 =begin description
 
@@ -45,5 +45,32 @@ eval_dies_ok 'my Digit $x = -1',
 eval_dies_ok 'my Digit $x = 3.1',
              'original type prevents assignment';
 
+# RT #67818
+{
+    subset Subhash of Hash;
+    #?rakudo todo 'RT #67818'
+    lives_ok { my Subhash $a = {} },
+             'can create subset of hash';
+
+    subset Person of Hash where { .keys.sort ~~ <firstname lastname> }
+    #?rakudo todo 'RT #67818'
+    lives_ok { my Person $p = { :firstname<Alpha>, :lastname<Bravo> } },
+             'can create subset of hash with where';
+
+    subset Austria of Array;
+    #?rakudo todo 'RT #67818'
+    lives_ok { my Austria $a = [] },
+             'can create subset of array';
+
+    subset Meercat of Pair;
+    lives_ok { my Meercat $p = :a<b> },
+             'can create subset of pair';
+
+    subset Sublist of List;
+    lives_ok { my Sublist $tsil = [] },
+             'can create subset of list';
+}
+
+
 
 # vim: ft=perl6

@p6rt
Copy link
Author

p6rt commented Jul 26, 2009

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

@p6rt
Copy link
Author

p6rt commented Oct 7, 2011

From @coke

On Thu Jul 23 06​:14​:43 2009, masak wrote​:

<masak> rakudo​: subset Person of Hash where { .keys.sort ~~ <firstname
lastname> }; my Person $p = { :firstname<Kyle>, :lastname<Ha> }
<p6eval> rakudo f5ccc0​: OUTPUT«Could not build C3 linearization​:
ambiguous hierarchy␤in sub trait_mod​:of [...]
<masak> I think I just found a bug. \o/
<masak> jnthn​: seen something like this before?
<jnthn> not seen that one before... :-S
<jnthn> report
<masak> rakudo​: subset Person of Hash; my Person $p = {}
<p6eval> rakudo f5ccc0​: OUTPUT«Could not build C3 linearization​:
ambiguous hierarchy␤in sub trait_mod​:of [...]
* masak reports
<masak> rakudo​: subset Austria of Array; my Austria $p = []
<p6eval> rakudo f5ccc0​: OUTPUT«Could not build C3 linearization​:
ambiguous hierarchy␤in sub trait_mod​:of [...]
<masak> rakudo​: subset Meercat of Pair; my Meercat $p = :a<b>
<p6eval> rakudo f5ccc0​: ( no output )
<masak> rakudo​: subset Austria of List; my Austria $p = []
<p6eval> rakudo f5ccc0​: ( no output )

So subtyping Pair and List works, but not subtyping Array or Hash.

14​:29 < [Coke]> rakudo​: subset Person of Hash where { .keys.sort ~~ <firstname
  lastname> }; my Person $p = { :firstname<Kyle>, :lastname<Ha>
  }; say $p.perl
14​:29 <+p6eval> rakudo 1c2c2d​: OUTPUT«{"firstname" => "Kyle", "lastname" =>
  "Ha"}␤»

14​:29 < [Coke]> rakudo​: subset Austria of Array; my Austria $p = []
14​:29 <+p6eval> rakudo 1c2c2d​: ( no output )

Both seem to work now. testsplz.

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Oct 7, 2011

From @coke

On Fri Oct 07 11​:30​:08 2011, coke wrote​:

On Thu Jul 23 06​:14​:43 2009, masak wrote​:

<masak> rakudo​: subset Person of Hash where { .keys.sort ~~
<firstname
lastname> }; my Person $p = { :firstname<Kyle>, :lastname<Ha> }
<p6eval> rakudo f5ccc0​: OUTPUT«Could not build C3 linearization​:
ambiguous hierarchy␤in sub trait_mod​:of [...]
<masak> I think I just found a bug. \o/
<masak> jnthn​: seen something like this before?
<jnthn> not seen that one before... :-S
<jnthn> report
<masak> rakudo​: subset Person of Hash; my Person $p = {}
<p6eval> rakudo f5ccc0​: OUTPUT«Could not build C3 linearization​:
ambiguous hierarchy␤in sub trait_mod​:of [...]
* masak reports
<masak> rakudo​: subset Austria of Array; my Austria $p = []
<p6eval> rakudo f5ccc0​: OUTPUT«Could not build C3 linearization​:
ambiguous hierarchy␤in sub trait_mod​:of [...]
<masak> rakudo​: subset Meercat of Pair; my Meercat $p = :a<b>
<p6eval> rakudo f5ccc0​: ( no output )
<masak> rakudo​: subset Austria of List; my Austria $p = []
<p6eval> rakudo f5ccc0​: ( no output )

So subtyping Pair and List works, but not subtyping Array or Hash.

14​:29 < [Coke]> rakudo​: subset Person of Hash where { .keys.sort ~~
<firstname
lastname> }; my Person $p = { :firstname<Kyle>,
:lastname<Ha>
}; say $p.perl
14​:29 <+p6eval> rakudo 1c2c2d​: OUTPUT«{"firstname" => "Kyle",
"lastname" =>
"Ha"}␤»

14​:29 < [Coke]> rakudo​: subset Austria of Array; my Austria $p = []
14​:29 <+p6eval> rakudo 1c2c2d​: ( no output )

Both seem to work now. testsplz.

ah, already haztests.

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Oct 7, 2011

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

@p6rt p6rt closed this as completed Oct 7, 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