I have this program:
class Foo {
has $.first;
}
my $a = Attribute.new(
:name('$!second'),
:type(Int),
:package('Foo'),
:has_accessor(True)
);
Foo.^add_attribute($a);
Foo.^compose;
Foo.^attributes».say; # Mu $!firstInt $!second
my $foo = Foo.new: :42first, :21second;
$foo.second.say; # P6opaque: no such attribute '$!second' on type Foo in a Foo when trying to get a value
The attributes
method shows that the attribute has been added, creating an object apparently succeeds, yet when I try to access the $!second
attribute I receive an error.
What am I missing?