This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
op.c: Move common vars check into the peephole optimiser
[perl5.git] / t / op / lvref.t
CommitLineData
72ed4618
FC
1BEGIN {
2 chdir 't';
3 require './test.pl';
4 set_up_inc("../lib");
5}
6
f52983f2 7plan 148;
72ed4618 8
72ed4618
FC
9eval '\$x = \$y';
10like $@, qr/^Experimental lvalue references not enabled/,
11 'error when feature is disabled';
26a50d99
FC
12eval '\($x) = \$y';
13like $@, qr/^Experimental lvalue references not enabled/,
14 'error when feature is disabled (aassign)';
72ed4618 15
3ad7d304 16use feature 'lvalue_refs', 'state';
72ed4618
FC
17
18{
19 my($w,$c);
20 local $SIG{__WARN__} = sub { $c++; $w = shift };
21 eval '\$x = \$y';
22 is $c, 1, 'one warning from lv ref assignment';
23 like $w, qr/^Lvalue references are experimental/,
24 'experimental warning';
26a50d99
FC
25 undef $c;
26 eval '\($x) = \$y';
27 is $c, 1, 'one warning from lv ref list assignment';
28 like $w, qr/^Lvalue references are experimental/,
29 'experimental warning';
72ed4618
FC
30}
31
32no warnings 'experimental::lvalue_refs';
33
34# Scalars
35
3813a8f3 36\$x = \$y;
72ed4618
FC
37is \$x, \$y, '\$pkg_scalar = ...';
38my $m;
53abf431 39\$m = \$y;
72ed4618 40is \$m, \$y, '\$lexical = ...';
fc048fcf 41\my $n = \$y;
72ed4618
FC
42is \$n, \$y, '\my $lexical = ...';
43@_ = \$_;
26a50d99 44\($x) = @_;
72ed4618 45is \$x, \$_, '\($pkgvar) = ... gives list context';
238ef7dc 46undef *x;
26a50d99 47(\$x) = @_;
238ef7dc 48is \$x, \$_, '(\$pkgvar) = ... gives list context';
72ed4618 49my $o;
c146a62a 50\($o) = @_;
72ed4618 51is \$o, \$_, '\($lexical) = ... gives list cx';
26a50d99 52my $q;
c146a62a 53(\$q) = @_;
238ef7dc 54is \$q, \$_, '(\$lexical) = ... gives list cx';
c146a62a 55\(my $p) = @_;
72ed4618 56is \$p, \$_, '\(my $lexical) = ... gives list cx';
c146a62a 57(\my $r) = @_;
238ef7dc 58is \$r, \$_, '(\my $lexical) = ... gives list cx';
c146a62a 59\my($s) = @_;
238ef7dc 60is \$s, \$_, '\my($lexical) = ... gives list cx';
217e3565 61\($_a, my $a) = @{[\$b, \$c]};
72ed4618
FC
62is \$_a, \$b, 'package scalar in \(...)';
63is \$a, \$c, 'lex scalar in \(...)';
c146a62a 64(\$_b, \my $b) = @{[\$b, \$c]};
72ed4618
FC
65is \$_b, \$::b, 'package scalar in (\$foo, \$bar)';
66is \$b, \$c, 'lex scalar in (\$foo, \$bar)';
2a57afb1
FC
67is do { \local $l = \3; $l }, 3, '\local $scalar assignment';
68is $l, undef, 'localisation unwound';
69is do { \(local $l) = \4; $l }, 4, '\(local $scalar) assignment';
11ea28ee 70is $l, undef, 'localisation unwound';
29a3d628
FC
71\$foo = \*bar;
72is *foo{SCALAR}, *bar{GLOB}, 'globref-to-scalarref assignment';
30bccb25 73for (1,2) {
3ad7d304
FC
74 \my $x = \3,
75 \my($y) = \3,
76 \state $a = \3,
77 \state($b) = \3 if $_ == 1;
30bccb25
FC
78 if ($_ == 2) {
79 is $x, undef, '\my $x = ... clears $x on scope exit';
80 is $y, undef, '\my($x) = ... clears $x on scope exit';
3ad7d304
FC
81 is $a, 3, '\state $x = ... does not clear $x on scope exit';
82 is $b, 3, '\state($x) = ... does not clear $x on scope exit';
30bccb25
FC
83 }
84}
72ed4618
FC
85
86# Array Elements
87
0ca7b7f7
FC
88sub expect_scalar_cx { wantarray ? 0 : \$_ }
89sub expect_list_cx { wantarray ? (\$_,\$_) : 0 }
90\$a[0] = expect_scalar_cx;
6102323a 91is \$a[0], \$_, '\$array[0]';
0ca7b7f7 92\($a[1]) = expect_list_cx;
6102323a
FC
93is \$a[1], \$_, '\($array[0])';
94{
95 my @a;
0ca7b7f7 96 \$a[0] = expect_scalar_cx;
6102323a 97 is \$a[0], \$_, '\$lexical_array[0]';
0ca7b7f7 98 \($a[1]) = expect_list_cx;
6102323a 99 is \$a[1], \$_, '\($lexical_array[0])';
40d2b828
FC
100 my $tmp;
101 {
102 \local $a[0] = \$tmp;
103 is \$a[0], \$tmp, '\local $a[0]';
104 }
105 is \$a[0], \$_, '\local $a[0] unwound';
106 {
107 \local ($a[1]) = \$tmp;
108 is \$a[1], \$tmp, '\local ($a[0])';
109 }
110 is \$a[1], \$_, '\local $a[0] unwound';
6102323a 111}
0ca7b7f7
FC
112{
113 my @a;
114 \@a[0,1] = expect_list_cx;
115 is \$a[0].\$a[1], \$_.\$_, '\@array[indices]';
116 \(@a[2,3]) = expect_list_cx;
117 is \$a[0].\$a[1], \$_.\$_, '\(@array[indices])';
118 my $tmp;
119 {
120 \local @a[0,1] = (\$tmp)x2;
121 is \$a[0].\$a[1], \$tmp.\$tmp, '\local @a[indices]';
122 }
123 is \$a[0].\$a[1], \$_.\$_, '\local @a[indices] unwound';
124}
72ed4618
FC
125
126# Hash Elements
127
5f94141d
FC
128\$h{a} = expect_scalar_cx;
129is \$h{a}, \$_, '\$hash{a}';
130\($h{b}) = expect_list_cx;
131is \$h{b}, \$_, '\($hash{a})';
132{
901f0970 133 my %h;
5f94141d
FC
134 \$h{a} = expect_scalar_cx;
135 is \$h{a}, \$_, '\$lexical_array{a}';
136 \($h{b}) = expect_list_cx;
137 is \$h{b}, \$_, '\($lexical_array{a})';
138 my $tmp;
139 {
140 \local $h{a} = \$tmp;
141 is \$h{a}, \$tmp, '\local $h{a}';
142 }
143 is \$h{a}, \$_, '\local $h{a} unwound';
144 {
145 \local ($h{b}) = \$tmp;
146 is \$h{b}, \$tmp, '\local ($h{a})';
147 }
148 is \$h{b}, \$_, '\local $h{a} unwound';
149}
150{
901f0970 151 my %h;
5f94141d
FC
152 \@h{"a","b"} = expect_list_cx;
153 is \$h{a}.\$h{b}, \$_.\$_, '\@hash{indices}';
154 \(@h{2,3}) = expect_list_cx;
155 is \$h{a}.\$h{b}, \$_.\$_, '\(@hash{indices})';
156 my $tmp;
157 {
158 \local @h{"a","b"} = (\$tmp)x2;
159 is \$h{a}.\$h{b}, \$tmp.\$tmp, '\local @h{indices}';
160 }
161 is \$h{a}.\$h{b}, \$_.\$_, '\local @h{indices} unwound';
162}
72ed4618
FC
163
164# Arrays
165
4779e7f9
FC
166package ArrayTest {
167 BEGIN { *is = *main::is }
168 sub expect_scalar_cx { wantarray ? 0 : \@ThatArray }
169 sub expect_list_cx { wantarray ? (\$_,\$_) : 0 }
170 sub expect_list_cx_a { wantarray ? (\@ThatArray)x2 : 0 }
3813a8f3 171 \@a = expect_scalar_cx;
4779e7f9
FC
172 is \@a, \@ThatArray, '\@pkg';
173 my @a;
3f114923 174 \@a = expect_scalar_cx;
4779e7f9 175 is \@a, \@ThatArray, '\@lexical';
9782ce69 176 (\@b) = expect_list_cx_a;
4779e7f9
FC
177 is \@b, \@ThatArray, '(\@pkg)';
178 my @b;
9782ce69 179 (\@b) = expect_list_cx_a;
4779e7f9 180 is \@b, \@ThatArray, '(\@lexical)';
3f114923 181 \my @c = expect_scalar_cx;
4779e7f9 182 is \@c, \@ThatArray, '\my @lexical';
bdaf10a5 183 (\my @d) = expect_list_cx_a;
4779e7f9 184 is \@d, \@ThatArray, '(\my @lexical)';
bdaf10a5
FC
185 \(@e) = expect_list_cx;
186 is \$e[0].\$e[1], \$_.\$_, '\(@pkg)';
4779e7f9 187 my @e;
bdaf10a5
FC
188 \(@e) = expect_list_cx;
189 is \$e[0].\$e[1], \$_.\$_, '\(@lexical)';
190 \(my @f) = expect_list_cx;
191 is \$f[0].\$f[1], \$_.\$_, '\(my @lexical)';
192 \my(@g) = expect_list_cx;
193 is \$g[0].\$g[1], \$_.\$_, '\my(@lexical)';
30494daf 194 my $old = \@h;
30494daf
FC
195 {
196 \local @h = \@ThatArray;
197 is \@h, \@ThatArray, '\local @a';
198 }
30494daf
FC
199 is \@h, $old, '\local @a unwound';
200 $old = \@i;
3813a8f3 201 {
30494daf
FC
202 (\local @i) = \@ThatArray;
203 is \@i, \@ThatArray, '(\local @a)';
3813a8f3 204 }
30494daf 205 is \@i, $old, '(\local @a) unwound';
4779e7f9 206}
30bccb25 207for (1,2) {
3ad7d304
FC
208 \my @x = [1..3],
209 \my(@y) = \3,
210 \state @a = [1..3],
211 \state(@b) = \3 if $_ == 1;
30bccb25
FC
212 if ($_ == 2) {
213 is @x, 0, '\my @x = ... clears @x on scope exit';
214 is @y, 0, '\my(@x) = ... clears @x on scope exit';
3ad7d304
FC
215 is "@a", "1 2 3", '\state @x = ... does not clear @x on scope exit';
216 is "@b", 3, '\state(@x) = ... does not clear @x on scope exit';
30bccb25
FC
217 }
218}
72ed4618
FC
219
220# Hashes
221
87da42eb
FC
222package HashTest {
223 BEGIN { *is = *main::is }
224 sub expect_scalar_cx { wantarray ? 0 : \%ThatHash }
225 sub expect_list_cx { wantarray ? (\%ThatHash)x2 : 0 }
3f114923 226 \%a = expect_scalar_cx;
87da42eb
FC
227 is \%a, \%ThatHash, '\%pkg';
228 my %a;
3f114923 229 \%a = expect_scalar_cx;
87da42eb 230 is \%a, \%ThatHash, '\%lexical';
9782ce69
FC
231 (\%b) = expect_list_cx;
232 is \%b, \%ThatHash, '(\%pkg)';
87da42eb 233 my %b;
9782ce69 234 (\%b) = expect_list_cx;
87da42eb 235 is \%b, \%ThatHash, '(\%lexical)';
3f114923 236 \my %c = expect_scalar_cx;
87da42eb 237 is \%c, \%ThatHash, '\my %lexical';
9782ce69 238 (\my %d) = expect_list_cx;
87da42eb 239 is \%d, \%ThatHash, '(\my %lexical)';
30494daf 240 my $old = \%h;
30494daf
FC
241 {
242 \local %h = \%ThatHash;
243 is \%h, \%ThatHash, '\local %a';
244 }
30494daf
FC
245 is \%h, $old, '\local %a unwound';
246 $old = \%i;
3813a8f3 247 {
30494daf
FC
248 (\local %i) = \%ThatHash;
249 is \%i, \%ThatHash, '(\local %a)';
3813a8f3 250 }
30494daf 251 is \%i, $old, '(\local %a) unwound';
87da42eb 252}
30bccb25 253for (1,2) {
3ad7d304 254 \state %y = {1,2},
30bccb25
FC
255 \my %x = {1,2} if $_ == 1;
256 if ($_ == 2) {
257 is %x, 0, '\my %x = ... clears %x on scope exit';
3ad7d304 258 is "@{[%y]}", "1 2", '\state %x = ... does not clear %x on scope exit';
30bccb25
FC
259 }
260}
72ed4618
FC
261
262# Subroutines
263
408e9044
FC
264package CodeTest {
265 BEGIN { *is = *main::is; }
3ad7d304 266 use feature 'lexical_subs';
408e9044
FC
267 no warnings 'experimental::lexical_subs';
268 sub expect_scalar_cx { wantarray ? 0 : \&ThatSub }
269 sub expect_list_cx { wantarray ? (\&ThatSub)x2 : 0 }
270 \&a = expect_scalar_cx;
271 is \&a, \&ThatSub, '\&pkg';
272 my sub a;
273 \&a = expect_scalar_cx;
274 is \&a, \&ThatSub, '\&mysub';
275 state sub as;
276 \&as = expect_scalar_cx;
277 is \&as, \&ThatSub, '\&statesub';
278 (\&b) = expect_list_cx;
279 is \&b, \&ThatSub, '(\&pkg)';
280 my sub b;
281 (\&b) = expect_list_cx;
282 is \&b, \&ThatSub, '(\&mysub)';
283 my sub bs;
284 (\&bs) = expect_list_cx;
285 is \&bs, \&ThatSub, '(\&statesub)';
286 \(&c) = expect_list_cx;
287 is \&c, \&ThatSub, '\(&pkg)';
288 my sub b;
289 \(&c) = expect_list_cx;
290 is \&c, \&ThatSub, '\(&mysub)';
291 my sub bs;
292 \(&cs) = expect_list_cx;
293 is \&cs, \&ThatSub, '\(&statesub)';
294}
72ed4618 295
b7ae253e 296# Mixed List Assignments
72ed4618 297
26a50d99 298(\$tahi, $rua) = \(1,2);
9fc71ff4
FC
299is join(' ', $tahi, $$rua), '1 2',
300 'mixed scalar ref and scalar list assignment';
f52983f2
FC
301$_ = 1;
302\($bb, @cc, %dd, &ee, $_==1 ? $ff : @ff, $_==2 ? $gg : @gg, (@hh)) =
303 (\$BB, \@CC, \%DD, \&EE, \$FF, \@GG, \1, \2, \3);
304is \$bb, \$BB, '\$scalar in list assignment';
305is \@cc, \@CC, '\@array in list assignment';
306is \%dd, \%DD, '\%hash in list assignment';
307is \&ee, \&EE, '\&code in list assignment';
308is \$ff, \$FF, '$scalar in \ternary in list assignment';
309is \@gg, \@GG, '@gg in \ternary in list assignment';
310is "@hh", '1 2 3', '\(@array) in list assignment';
b7ae253e
FC
311
312# Conditional expressions
313
9fc71ff4 314$_ = 3;
d1094c5b 315$_ == 3 ? \$tahi : $rua = \3;
9fc71ff4 316is $tahi, 3, 'cond assignment resolving to scalar ref';
d1094c5b 317$_ == 0 ? \$toru : $wha = \3;
9fc71ff4 318is $$wha, 3, 'cond assignment resolving to scalar';
d1094c5b 319$_ == 3 ? \$rima : \$ono = \5;
9e592f5a 320is $rima, 5, 'cond assignment with refgens on both branches';
7664512e
FC
321\($_ == 3 ? $whitu : $waru) = \5;
322is $whitu, 5, '\( ?: ) assignment';
f52983f2
FC
323\($_ == 3 ? $_ < 4 ? $ii : $_ : $_) = \$_;
324is \$ii, \$_, 'nested \ternary assignment';
72ed4618 325
096cc2cc
FC
326# Foreach
327
362e758e
FC
328for \my $topic (\$for1, \$for2) {
329 push @for, \$topic;
330}
096cc2cc 331is "@for", \$for1 . ' ' . \$for2, 'foreach \my $a';
362e758e
FC
332is \$topic, \$::topic, 'for \my scoping';
333
334@for = ();
335for \$::a(\$for1, \$for2) {
336 push @for, \$::a;
337}
338is "@for", \$for1 . ' ' . \$for2, 'foreach \$::a';
096cc2cc
FC
339
340@for = ();
362e758e 341for \my @a([1,2], [3,4]) {
096cc2cc 342 push @for, @a;
362e758e 343}
096cc2cc
FC
344is "@for", "1 2 3 4", 'foreach \my @a [perl #22335]';
345
346@for = ();
362e758e
FC
347for \@::a([1,2], [3,4]) {
348 push @for, @::a;
349}
350is "@for", "1 2 3 4", 'foreach \@::a [perl #22335]';
351
352@for = ();
353for \my %a({5,6}, {7,8}) {
096cc2cc 354 push @for, %a;
362e758e 355}
096cc2cc
FC
356is "@for", "5 6 7 8", 'foreach \my %a [perl #22335]';
357
358@for = ();
362e758e
FC
359for \%::a({5,6}, {7,8}) {
360 push @for, %::a;
361}
362is "@for", "5 6 7 8", 'foreach \%::a [perl #22335]';
363
364@for = ();
365{
366 use feature 'lexical_subs';
367 no warnings 'experimental::lexical_subs';
368 my sub a;
369 for \&a(sub {9}, sub {10}) {
096cc2cc
FC
370 push @for, &a;
371 }
362e758e
FC
372}
373is "@for", "9 10", 'foreach \&padcv';
096cc2cc 374
362e758e
FC
375@for = ();
376for \&::a(sub {9}, sub {10}) {
377 push @for, &::a;
378}
379is "@for", "9 10", 'foreach \&rv2cv';
096cc2cc 380
72ed4618
FC
381# Errors
382
b3717a0e
FC
383eval { my $x; \$x = 3 };
384like $@, qr/^Assigned value is not a reference at/, 'assigning non-ref';
385eval { my $x; \$x = [] };
386like $@, qr/^Assigned value is not a SCALAR reference at/,
387 'assigning non-scalar ref to scalar ref';
d8a875d9
FC
388eval { \$::x = [] };
389like $@, qr/^Assigned value is not a SCALAR reference at/,
390 'assigning non-scalar ref to package scalar ref';
0719038d
FC
391eval { my @x; \@x = {} };
392like $@, qr/^Assigned value is not an ARRAY reference at/,
393 'assigning non-array ref to array ref';
394eval { \@::x = {} };
395like $@, qr/^Assigned value is not an ARRAY reference at/,
396 'assigning non-array ref to package array ref';
397eval { my %x; \%x = [] };
398like $@, qr/^Assigned value is not a HASH reference at/,
399 'assigning non-hash ref to hash ref';
400eval { \%::x = [] };
401like $@, qr/^Assigned value is not a HASH reference at/,
402 'assigning non-hash ref to package hash ref';
408e9044
FC
403eval { use feature 'lexical_subs';
404 no warnings 'experimental::lexical_subs';
405 my sub x; \&x = [] };
406like $@, qr/^Assigned value is not a CODE reference at/,
407 'assigning non-code ref to lexical code ref';
408eval { \&::x = [] };
409like $@, qr/^Assigned value is not a CODE reference at/,
410 'assigning non-code ref to package code ref';
d6378458 411
bd9bf01b
FC
412eval { my $x; (\$x) = 3 };
413like $@, qr/^Assigned value is not a reference at/,
414 'list-assigning non-ref';
415eval { my $x; (\$x) = [] };
416like $@, qr/^Assigned value is not a SCALAR reference at/,
417 'list-assigning non-scalar ref to scalar ref';
418eval { (\$::x = []) };
419like $@, qr/^Assigned value is not a SCALAR reference at/,
420 'list-assigning non-scalar ref to package scalar ref';
421eval { my @x; (\@x) = {} };
422like $@, qr/^Assigned value is not an ARRAY reference at/,
423 'list-assigning non-array ref to array ref';
424eval { (\@::x) = {} };
425like $@, qr/^Assigned value is not an ARRAY reference at/,
426 'list-assigning non-array ref to package array ref';
427eval { my %x; (\%x) = [] };
428like $@, qr/^Assigned value is not a HASH reference at/,
429 'list-assigning non-hash ref to hash ref';
430eval { (\%::x) = [] };
431like $@, qr/^Assigned value is not a HASH reference at/,
432 'list-assigning non-hash ref to package hash ref';
408e9044
FC
433eval { use feature 'lexical_subs';
434 no warnings 'experimental::lexical_subs';
435 my sub x; (\&x) = [] };
436like $@, qr/^Assigned value is not a CODE reference at/,
437 'list-assigning non-code ref to lexical code ref';
438eval { (\&::x) = [] };
439like $@, qr/^Assigned value is not a CODE reference at/,
440 'list-assigning non-code ref to package code ref';
bd9bf01b 441
d6378458
FC
442eval '(\do{}) = 42';
443like $@, qr/^Can't modify reference to do block in list assignment at /,
444 "Can't modify reference to do block in list assignment";
d6378458
FC
445eval '(\pos) = 42';
446like $@,
447 qr/^Can't modify reference to match position in list assignment at /,
448 "Can't modify ref to some scalar-returning op in list assignment";
d6378458
FC
449eval '(\glob) = 42';
450like $@,
451 qr/^Can't modify reference to glob in list assignment at /,
452 "Can't modify reference to some list-returning op in list assignment";
d6b7592f
FC
453eval '\pos = 42';
454like $@,
455 qr/^Can't modify reference to match position in scalar assignment at /,
456 "Can't modify ref to some scalar-returning op in scalar assignment";
30494daf
FC
457eval '\(local @b) = 42';
458like $@,
bdaf10a5 459 qr/^Can't modify reference to localized parenthesized array in list(?x:
30494daf
FC
460 ) assignment at /,
461 q"Can't modify \(local @array) in list assignment";
462eval '\local(@b) = 42';
463like $@,
bdaf10a5 464 qr/^Can't modify reference to localized parenthesized array in list(?x:
30494daf
FC
465 ) assignment at /,
466 q"Can't modify \local(@array) in list assignment";
bdaf10a5
FC
467eval '\local(@{foo()}) = 42';
468like $@,
469 qr/^Can't modify reference to array dereference in list assignment at/,
470 q"'Array deref' error takes prec. over 'local paren' error";
87da42eb
FC
471eval '\(%b) = 42';
472like $@,
473 qr/^Can't modify reference to parenthesized hash in list assignment a/,
474 "Can't modify ref to parenthesized package hash in scalar assignment";
475eval '\(my %b) = 42';
476like $@,
477 qr/^Can't modify reference to parenthesized hash in list assignment a/,
478 "Can't modify ref to parenthesized hash (\(my %b)) in list assignment";
479eval '\my(%b) = 42';
480like $@,
481 qr/^Can't modify reference to parenthesized hash in list assignment a/,
482 "Can't modify ref to parenthesized hash (\my(%b)) in list assignment";
483eval '\%{"42"} = 42';
484like $@,
485 qr/^Can't modify reference to hash dereference in scalar assignment a/,
486 "Can't modify reference to hash dereference in scalar assignment";
63702de8
FC
487eval '$foo ? \%{"42"} : \%43 = 42';
488like $@,
489 qr/^Can't modify reference to hash dereference in scalar assignment a/,
490 "Can't modify ref to whatever in scalar assignment via cond expr";
781ff25d
FC
491
492# Miscellaneous
493
494{
88cc83cb 495 local $::TODO = ' ';
781ff25d
FC
496 my($x,$y);
497 sub {
498 sub {
499 \$x = \$y;
500 }->();
501 is \$x, \$y, 'lexical alias affects outer closure';
502 }->();
503 is \$x, \$y, 'lexical alias affects outer sub where vars are declared';
504}
81cb1af6
FC
505
506{ # PADSTALE has a double meaning
3ad7d304 507 use feature 'lexical_subs', 'signatures';
81cb1af6
FC
508 no warnings 'experimental';
509 my $c;
510 my sub s ($arg) {
511 state $x = ++$c;
512 if ($arg == 3) { return $c }
513 goto skip if $arg == 2;
514 my $y;
515 skip:
516 # $y is PADSTALE the 2nd time
517 \$x = \$y if $arg == 2;
518 }
519 s(1);
520 s(2);
521 is s(3), 1, 'padstale alias should not reset state'
522}
cf5d2d91 523
cf5d2d91
FC
524SKIP: {
525 skip_without_dynamic_extension('List/Util');
526 require Scalar::Util;
527 my $a;
528 Scalar::Util::weaken($r = \$a);
529 \$a = $r;
530 pass 'no crash when assigning \$lex = $weakref_to_lex'
531}