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 refer to a constant declared in a class in Rakudo #1374
Comments
From @masakIn Rakudo 4c248e5c, constants can no longer be used inside of classes. $ perl6 -e'class A { constant B = 5; has $!x = B }; A.new' I'm pretty sure this used to work before jnthn++'s merge. Which means Sadly, it's not possible to refer to constants-defined-outside-a-class $ perl6 -e 'constant B = 5; class A { has $!x = B }; A.new' Here's a clean workaround, for those who want something like constants $ perl6 -e 'class A { sub B { 5 }; has $.x = B }; A.new.x.say' |
From @masakOn Thu Oct 22 04:05:08 2009, masak wrote:
<jnthn> Out of curiosity, does a lexical instead of a constant work? |
From [Unknown Contact. See original ticket]On Thu Oct 22 04:05:08 2009, masak wrote:
<jnthn> Out of curiosity, does a lexical instead of a constant work? |
@masak - Status changed from 'new' to 'open' |
From @kylehaThis is an automatically generated mail to inform you that tests are now available in t/spec/S04-declarations/constant.t commit 4384f9e3c5d22e1bbdf564c98773a2b1538e23eb [t/spec] tests for RT #69967, constant declarations and classes Inline Patchdiff --git a/t/spec/S04-declarations/constant.t b/t/spec/S04-declarations/constant.t
index b207465..e7aa000 100644
--- a/t/spec/S04-declarations/constant.t
+++ b/t/spec/S04-declarations/constant.t
@@ -246,6 +246,21 @@ plan *;
'assign constant its own value from expression';
}
+#?rakudo skip 'RT 69967'
+{
+ constant C = 6;
+ class A {
+ constant B = 5;
+ has $.x = B;
+ has $.y = A::B;
+ has $.z = C;
+ }
+
+ is A.new.x, 5, 'Can declare and use a constant in a class';
+ is A.new.y, 5, 'Can declare and use a constant with FQN in a class';
+ is A.new.z, 6, 'Can use outer constants in a class';
+}
+
done_testing;
# vim: ft=perl6 |
From @bbkrMentioned test is already unfudged and pass on NOM. |
@bbkr - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#69967 (status was 'resolved')
Searchable as RT69967$
The text was updated successfully, but these errors were encountered: