That seems to be the case:
class Foo { has $!bar }; say Foo.new( :3bar ).perl # OUTPUT: «Foo.new»
Documentation says it's implementation dependent, but I wonder if this actually makes sense.
The .perl
output is correct. Foo.new( :3bar )
does not do what you think. If you add a method bar() { $!bar }
, you'll notice that the private attribute $!bar
did not get set:
class Foo {
has $!bar;
method bar() { $!bar }
}
say Foo.new( :3bar ).bar; # (Any)
say Foo.new( :3bar ).perl; # Foo.new
The named parameter :3bar
(aka bar => 3
) is silently ignored, because there is no public attribute with the name bar
.
If you want it to complain about this situation, then maybe https://modules.raku.org/dist/StrictNamedArguments is something for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With