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

Checks in 'where' blocks of subtypes building on subtypes are not run in the right order in Rakudo #2222

Closed
p6rt opened this issue Oct 10, 2010 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Oct 10, 2010

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

Searchable as RT78322$

@p6rt
Copy link
Author

p6rt commented Oct 10, 2010

From @masak

$ perl6 -e 'subset A of Parcel where { .elems > 5 }; subset B of A
where { .[5] == 42 }; (1, 2, 3) ~~ B'
Use of uninitialized value in numeric context in <anon> at line 1

The warning comes from the fact that B's where block is called, when
in fact it shouldn't since A's where block should be called, return
False, and prevent B's block from ever running.

Note that this ticket is caused entirely by the issue in #​78318... but
it was deemed that a separate ticket for this would be good, because
we probably don't have tests for the above.

@p6rt
Copy link
Author

p6rt commented Dec 23, 2010

From @kyleha

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

commit 98abe8e910d8782900204f085099f6bab906ea5c
Author​: Kyle Hasselbacher <kyleha@​gmail.com>
Date​: Thu Dec 23 14​:56​:49 2010 -0600

  [subtypes.t] Test for RT #​78322

Inline Patch
diff --git a/S12-subset/subtypes.t b/S12-subset/subtypes.t
index a88130b..f1db1a0 100644
--- a/S12-subset/subtypes.t
+++ b/S12-subset/subtypes.t
@@ -190,6 +190,39 @@ ok "x" !~~ NW1, 'subset declaration without where clause rejects wrong value';
     is @*rt78318, <bug hunt>, 'code called when subtype built on subtype';
 }
 
+# RT #78322
+{
+    my $*call1;
+    my $*call2;
+
+    $*call1 = 0;$*call2 = 0;
+
+    subset RT78322 of Int     where { $*call1++; $^a == 78322 };
+    subset Bughunt of RT78322 where { $*call2++; ?1 };
+
+    $*call1 = 0;$*call2 = 0;
+    nok 22 ~~ RT78322, 'level one subset check is false';
+    is $*call1, 1, 'level one subset checked (should fail)';
+    is $*call2, 0, 'level two subset not checked';
+
+    #?rakudo 3 todo 'RT 78322'
+    $*call1 = 0;$*call2 = 0;
+    nok 22 ~~ Bughunt, 'overall subset check is false';
+    is $*call1, 1, 'level one subset checked (should fail)';
+    is $*call2, 0, 'level two subset not checked';
+
+    $*call1 = 0;$*call2 = 0;
+    ok 78322 ~~ RT78322, 'level one subset check is true';
+    is $*call1, 1, 'level one subset checked (should succeed)';
+    is $*call2, 0, 'level two subset not checked';
+
+    $*call1 = 0;$*call2 = 0;
+    ok 78322 ~~ Bughunt, 'overall subset check is true';
+    #?rakudo 2 todo 'RT 78322'
+    is $*call1, 1, 'level one subset checked (should succeed)';
+    is $*call2, 1, 'level two subset checked (should succeed)';
+}
+
 done_testing;
 
 # vim: ft=perl6

@p6rt
Copy link
Author

p6rt commented Dec 23, 2010

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

@p6rt
Copy link
Author

p6rt commented Apr 21, 2012

From @jnthn

On Sun Oct 10 16​:15​:54 2010, masak wrote​:

$ perl6 -e 'subset A of Parcel where { .elems > 5 }; subset B of A
where { .[5] == 42 }; (1, 2, 3) ~~ B'
Use of uninitialized value in numeric context in <anon> at line 1

The warning comes from the fact that B's where block is called, when
in fact it shouldn't since A's where block should be called, return
False, and prevent B's block from ever running.

Note that this ticket is caused entirely by the issue in #​78318... but
it was deemed that a separate ticket for this would be good, because
we probably don't have tests for the above.

Fixed probably when nom landed, tests added to cover it are already
running. Resolving.

/jnthn

@p6rt
Copy link
Author

p6rt commented Apr 21, 2012

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

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