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
Lexical subs aren't found from the where clause of a subset declaration in Rakudo #2085
Comments
From @masak<masak> rakudo: sub foo($a) { True; }; subset Foo of Mu where -> $foo |
From @kylehaThis is an automatically generated mail to inform you that tests are now available in t/spec/S02-polymorphic_types/subset.t commit a0a95f0a8680e04e3ff05592e9ddd3c8f93f9d2d [t/spec] tests for RT #77356, lexicals in subset declaration; also fix a few tests that made wrong assumptions about the scope of symbols (related to eval_dies_ok) Inline Patchdiff --git a/t/spec/S02-polymorphic_types/subset.t b/t/spec/S02-polymorphic_types/subset.t
index b9d9e4b..7d21f7d 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 33;
+plan 37;
=begin description
@@ -38,11 +38,11 @@ subset Digit of Int where ^10;
is $x, 9, "other end of range";
}
-eval_dies_ok 'my Digit $x = 10',
+dies_ok { my Digit $x = 10 },
'type constraints prevents assignment 1';
-eval_dies_ok 'my Digit $x = -1',
- 'type constraints prevents assignment 2';
-eval_dies_ok 'my Digit $x = 3.1',
+dies_ok { my Digit $x = -1 },
+ 'type constraints prevents assignment 2';
+dies_ok { my Digit $x = 3.1 },
'original type prevents assignment';
# RT #67818
@@ -148,4 +148,20 @@ eval_dies_ok 'my Digit $x = 3.1',
'subset A of Mu + type check and assignment works';
}
+# RT #77356
+#?rakudo skip 'RT 77356'
+{
+ sub limit() { 0 }
+ subset aboveLexLimit of Int where { $_ > limit() };
+ ok 1 ~~ aboveLexLimit, 'can use subset that depends on lexical sub (1)';
+ nok -1 ~~ aboveLexLimit, 'can use subset that depends on lexical sub (2)';
+}
+
+#?rakudo skip 'RT 77356'
+{
+ my $limit = 0;
+ subset aboveLexVarLimit of Int where { $_ > $limit };
+ ok 1 ~~ aboveLexVarLimit, 'can use subset that depends on lexical variable (1)';
+ nok -1 ~~ aboveLexVarLimit, 'can use subset that depends on lexical variable (2)';
+}
# vim: ft=perl6 |
The RT System itself - Status changed from 'new' to 'open' |
From @masak$ perl6 -e 'subset A of Any where { say "OH HAI" }; 42 ~~ A' Should be able to find &say, just like any other block. |
From @moritzworks now, tests pass |
@moritz - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#77356 (status was 'resolved')
Searchable as RT77356$
The text was updated successfully, but these errors were encountered: