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

Lexical subs aren't found from the where clause of a subset declaration in Rakudo #2085

Closed
p6rt opened this issue Aug 22, 2010 · 6 comments
Closed
Labels

Comments

@p6rt
Copy link

p6rt commented Aug 22, 2010

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

Searchable as RT77356$

@p6rt
Copy link
Author

p6rt commented Aug 22, 2010

From @masak

<masak> rakudo​: sub foo($a) { True; }; subset Foo of Mu where -> $foo
{ foo($foo) }; say 5 ~~ Foo # also found and unreported by
tylercurtis++
<p6eval> rakudo 928836​: OUTPUT«Could not find sub &foo [...]
* masak submits rakudobug
<masak> <pmichaud> probably the same one that caused (causes) roles to
not see lexical subs.
<moritz_> another fun not-in-the-right-lexical-context bug
<masak> right.

@p6rt
Copy link
Author

p6rt commented Aug 24, 2010

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 a0a95f0a8680e04e3ff05592e9ddd3c8f93f9d2d
Author​: moritz <moritz@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Tue Aug 24 11​:59​:22 2010 +0000

  [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)
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;32098 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 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

@p6rt
Copy link
Author

p6rt commented Aug 24, 2010

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

@p6rt
Copy link
Author

p6rt commented Oct 10, 2010

From @masak

$ perl6 -e 'subset A of Any where { say "OH HAI" }; 42 ~~ A'
Could not find sub &say

Should be able to find &say, just like any other block.

@p6rt
Copy link
Author

p6rt commented Mar 31, 2012

From @moritz

works now, tests pass

@p6rt
Copy link
Author

p6rt commented Mar 31, 2012

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

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