Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POD generates a syntax error #12

Open
brickpool opened this issue May 31, 2021 · 2 comments
Open

POD generates a syntax error #12

brickpool opened this issue May 31, 2021 · 2 comments

Comments

@brickpool
Copy link

brickpool commented May 31, 2021

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
Copy link
Owner

tobyink commented May 31, 2021

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

Should be $self?

@brickpool
Copy link
Author

    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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants