@@ -14,7 +14,7 @@ Class Attributes
14
14
# L<S12/Class attributes/"Class attributes are declared">
15
15
# L<S12/Class methods/Such a metaclass method is always delegated>
16
16
17
- plan 23 ;
17
+ plan 24 ;
18
18
19
19
class Foo {
20
20
our $ . bar = 23 ;
@@ -141,4 +141,29 @@ is_run(
141
141
' useless my $.a accessor method generation error contains useful enough hints'
142
142
);
143
143
144
+ # RT #130748
145
+ subtest ' attribute access from where clauses' => {
146
+ plan 7 ;
147
+ throws-like 「 my class RT130748a { has $.a; has $.b where $!a }」 ,
148
+ X::Syntax::NoSelf , ' where, thunk, attr only' ;
149
+ throws-like 「 my class RT130748b { has $.a; has $.b where * > $!a }」 ,
150
+ X::Syntax::NoSelf , ' where, whatevercode' ;
151
+ throws-like 「 my class RT130748c { has $.a; has $.b where {$!a}」 ,
152
+ X::Syntax::NoSelf , ' where, block' ;
153
+
154
+ my class RT130748d {
155
+ has $ . a = 42 ;
156
+ has $ . b where *. so = $ ! a + 1;
157
+ method z-thunk ($ x where $ ! a ) { pass ' where in method param, thunk' }
158
+ method z-block ($ x where {$ ! a }) { pass ' where in method param, block' }
159
+ method z-whatever ($ x where *+ $ ! a ) {
160
+ pass ' where in method param, whatevercode'
161
+ }
162
+ }
163
+ is-deeply RT130748d. new . b, 43 , ' can still use attr in default values' ;
164
+ RT130748d. new . z-thunk: 42 ;
165
+ RT130748d. new . z-block: 42 ;
166
+ RT130748d. new . z-whatever: 42 ;
167
+ }
168
+
144
169
# vim: ft=perl6
0 commit comments