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

Can't access a lexical 'my' variable situated in an immediate block from an 'our'-scoped routine situated in the same block in Rakudo #1908

Closed
p6rt opened this issue Jul 3, 2010 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jul 3, 2010

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

Searchable as RT76366$

@p6rt
Copy link
Author

p6rt commented Jul 3, 2010

From @masak

<masak> rakudo​: { my $a; our sub foo() { $a } }
<p6eval> rakudo 7017d2​: OUTPUT«===SORRY!===␤Symbol '$a' not
predeclared in foo [...]
<masak> bug or feature?
<jnthn> "feature" ;-)
<masak> grrrr...
<jnthn> (not really)
* masak submits rakudofeature
<jnthn> I think that should work.

@p6rt
Copy link
Author

p6rt commented Jul 16, 2010

From @jnthn

On Sat Jul 03 08​:01​:30 2010, masak wrote​:

<masak> rakudo​: { my $a; our sub foo() { $a } }
<p6eval> rakudo 7017d2​: OUTPUT«===SORRY!===␤Symbol '$a' not
predeclared in foo [...]
<masak> bug or feature?
<jnthn> "feature" ;-)
<masak> grrrr...
<jnthn> (not really)
* masak submits rakudofeature
<jnthn> I think that should work.

Now​:

02​:15 <@​jnthn> rakudo​: { my $a = 42; our sub foo() { $a } }; say foo()
02​:15 <+p6eval> rakudo d51e99​: OUTPUT«42␤»

Given to moritz++ for spectesting.

Thanks,

Jonathan

@p6rt
Copy link
Author

p6rt commented Jul 16, 2010

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

@p6rt
Copy link
Author

p6rt commented Jul 16, 2010

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

@p6rt p6rt closed this as completed Jul 16, 2010
@p6rt
Copy link
Author

p6rt commented Jul 16, 2010

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/S04-declarations/my.t

commit 250691a4b287c3ba06b94e5d107bd9e60cfcb20e
Author​: moritz <moritz@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Fri Jul 16 07​:46​:44 2010 +0000

  [t/spec] tests for RT #​76366, accessing lexicals through our-subs
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;31718 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/S04-declarations/my.t b/t/spec/S04-declarations/my.t
index b14c3c3..68b5bc0 100644
--- a/t/spec/S04-declarations/my.t
+++ b/t/spec/S04-declarations/my.t
@@ -1,7 +1,7 @@
 use v6;
 use Test;
 
-plan 63;
+plan 65;
 
 #L<S04/The Relationship of Blocks and Declarations/"declarations, all
 # lexically scoped declarations are visible"> 
@@ -232,6 +232,19 @@ my $z = 42;
     }
 }
 
+# used to be RT #76366
+{
+    lives_ok { access_lexical_a() },
+        'can call our-sub that accesses a lexical before the block was run';
+    {
+        my $a = 42;
+        our sub access_lexical_a() { $a }
+    }
+    is  access_lexical_a(), 42,
+        'can call our-sub that accesses a lexical after the block was run';
+
+}
+
 eval_lives_ok 'my (%h?)', 'my (%h?) lives';
 
 #RT 63588

@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