On Sun, 25 Jun 2017 23:14:00 -0700, ben-goldb...@hotmail.com wrote: > Here's an IRC snippet showing the problem: > > <BenGoldberg> m: await start { my $a = "strange"; $a does role Test { > }; } xx 16 > <+camelia> rakudo-moar 9936a3: OUTPUT: «Tried to get the result of a > broken Promise in block <unit> at <tmp> line 1Original exception: > Incompatible MROs in P6opaque rebless for types Str+{Test} and > Str+{Test} in block at <tmp> line 1» > > Using a Lock solves the problem, but there ought to be a better > solution. > > <BenGoldberg> m: my $l = Lock.new; await start { my $a = "dubba"; role > Test { }; $l.protect: { $a does Test }; } xx 16 > <+camelia> rakudo-moar 9936a3: ( no output ) > I think you wanted `but`. `does` is in-place, and you're therefore in-place mutating a string from the constant table in this case and that will have global effect on the program. Such things will likely at some point become an error. Note that if this was successful, it would be applying the role Test to the same thing 16 times.
It's easy to remember which of the in-place mutation operators in Perl 6 are threadsafe, because none of them are (does, ++, --, the = meta-operator, and so forth). So, rejecting as it was never intended that concurrently mixing in to the same object without any kind of protection would work out, and the original code is probably confused and wanted to use `but` anyway. /jnthn