tobyink / p5-zydeco

Perl 5 distribution Zydeco; see homepage for downloads and documentation.
https://zydeco.toby.ink/
14 stars 3 forks source link

POD generates a syntax error #12

Open brickpool opened 3 years ago

brickpool commented 3 years ago

A syntax error is generated when using inline POD.

I have created the following small test script.

package Pod {
  use Zydeco;

  class Test {
    has foo = 0;
    method bar() = self->foo();

=pod

=cut

    method baz() = self->foo();

  }
}

use strict;
use warnings;
use Test::More;

isa_ok Pod::Test->new(), 'Pod::Test'; 

done_testing;

This is the associated error message

syntax error at H:\temp\Perl\test.pl line 8, near ";="
Global symbol "$self" requires explicit package name (did you forget to declare "my $self"?) at H:\temp\Perl\test.pl line 12.
BEGIN not safe after errors--compilation aborted at H:\temp\Perl\test.pl line 14.

I am using the current Zydeco library version and Perl version 5.26.3. Compiling and testing succeeds without a POD or if line 6 is changed as follows:

method bar() { $self->foo() };

or

method bar() = $self->foo();;

Please note that in this case the additional semicolon must be used at the end.

ok 1 - An object of class 'Pod::Test' isa 'Pod::Test'
1..1
tobyink commented 3 years ago
    method bar() = self->foo();

Should be $self?

brickpool commented 3 years ago
    method bar() = self->foo();

Should be $self?

Yes, that's right, there is a typo in my message. The script uses $self. Here as copy & paste

package Pod {
  use Zydeco;

  class Test {
    has foo = 0;
    method bar() = $self->foo();

;#fix pod bug

=pod

=cut

    method baz() = $self->foo();
  }
}

use strict;
use warnings;
use Test::More;

isa_ok Pod::Test->new(), 'Pod::Test'; 

done_testing;