Skip to content

Commit c9874ca

Browse files
committed
Optimizer stress test for is rw on multis.
1 parent 059757b commit c9874ca

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

S06-multi/by-trait.t

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use v6;
22
use Test;
3-
plan 5;
3+
plan 6;
44

55
# originally for RT #66588, which was closed
66
# RT #74414 is related, and works on moar, but
@@ -24,4 +24,19 @@ plan 5;
2424
is $rw_call, 1, 'read-write multi was called';
2525
}
2626

27+
#?rakudo.jvm skip 'Ambiguous dispatch'
28+
{
29+
# Makes sure dynamic optimization copes with the rw vs. ro distinction
30+
# also (early patches to the MoarVM multi cache didn't handle this, so
31+
# we could end up inlining the wrong thing; other backends are likely
32+
# to intensively optimize multi calls too, and could hit the same kind
33+
# of trap).
34+
multi foo($x is rw) { 1 };
35+
multi foo($x) { 2 };
36+
foo [];
37+
my $got;
38+
for ^500 { $got = foo $ = []; }
39+
is $got, 1, 'Optimization respects is rw';
40+
}
41+
2742
# vim: ft=perl6

0 commit comments

Comments
 (0)