I have this method in a class that's throwing a Cannot bind attributes in a Nil type object. Did you forget a '.new'?
method parse() {
grammar FindHeaders {
token TOP { [<not-header> | <header>]+ $ }
token not-header { ^^ <![#]> \N* \n }
token header { ^^ '#'{ 1 .. 6 } <content> \n }
token content { \N+ }
}
class HeaderActions {
method content($match) {
return if $match ~~ m/^^\#\s+<[A..Z]>+e*s/ || $match !~~ m/<[a..z]>/;
return if $match ~~ m/\|/ && ( $match ~~ m:i/project/ || $match ~~ m:i/\+\w/ );
my $tc = Lingua::EN::Titlecase.new($match);
my $new_title = $tc.title;
make($new_title);
}
}
my $t = $!content;
FindHeaders.parse($t, actions => HeaderActions.new);
}
As far as I can tell, this code matches what's in the official documentation. So not sure why I'm getting this error. I have no idea what attribute or Nil object the compiler is referring to. If I comment out the line with the make
method, everything works fine.
make
may be trying to access the class theparse
method is in. Maybe a bug? – Damalusmake
method, everything works fine." Your code doesn't include use of a.make
method. "As far as I can tell, this code matches what's in the official documentation." From the official doc formake
: "The sub form operates on the current Match$/
". So the "Nil
object the compiler is referring to" is the "value" (aNil
is a value representing a lack of a value) that's bound to$/
when themake
sub call is evaluated. – Reactionary