Skip Menu |
 

This queue is for tickets about the Future-AsyncAwait CPAN distribution.

Report information
The Basics
Id: 131571
Status: patched
Priority: 0/
Queue: Future-AsyncAwait

People
Owner: Nobody in particular
Requestors: skaji [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Future::AsyncAwait does not work with subroutine signatures + attributes
Download (untitled) / with headers
text/plain 357b
This is a nitpicking, but I report it. ``` package Foo; use Future::AsyncAwait; use experimental 'signatures'; sub new ($class) { bless {}, $class; } async sub open :method ($self, $path) { ...; } ``` ``` ❯ perl -c Foo.pm Invalid CODE attribute: method($self, $path) at Foo.pm line 12. BEGIN failed--compilation aborted at Foo.pm line 12. ```
Download (untitled) / with headers
text/plain 111b
The reason to report nitpickings is that I'd love to see async-await support in perl core in the near future :)
Download (untitled) / with headers
text/plain 558b
Ah; I suspect a bug in the lexer extension for parsing attributes. It accepts whitespace between the attribute name and parenthesized argument string, which it isn't supposed to. The regular perl parser doesn't: $ perl -Mfeature=signatures -ce 'sub x :method ($self) {}' The signatures feature is experimental at -e line 1. -e syntax OK leo@shy:~/src/perl/Future-AsyncAwait [bzr] $ perl -Mfeature=signatures -ce 'sub x :method($self) {}' Invalid CODE attribute: method($self) at -e line 1. BEGIN failed--compilation aborted at -e line 1. -- Paul Evans
Download (untitled) / with headers
text/plain 381b
On Mon Jan 27 18:06:12 2020, PEVANS wrote: Show quoted text
> Ah; I suspect a bug in the lexer extension for parsing attributes. It > accepts whitespace between the attribute name and parenthesized > argument string, which it isn't supposed to.
Yup. Turns out to be a simple fix by removing a line of code. $ perl -Mblib -c rt131571.pl rt131571.pl syntax OK Patch attached. -- Paul Evans
Subject: rt131571.patch
Download rt131571.patch
text/x-diff 1.3k
=== modified file 'hax/lexer-additions.c.inc' --- old/hax/lexer-additions.c.inc 2019-12-01 01:44:11 +0000 +++ new/hax/lexer-additions.c.inc 2020-01-28 00:05:18 +0000 @@ -78,7 +78,7 @@ if(!ret) return ret; - lex_read_space(0); + /* Do not read space here as space is not allowed between NAME(ARGS) */ if(lex_peek_unichar(0) != '(') return ret; === modified file 't/44sub-attrs.t' --- old/t/44sub-attrs.t 2019-07-05 14:27:39 +0000 +++ new/t/44sub-attrs.t 2020-01-28 00:05:18 +0000 @@ -34,6 +34,8 @@ # some custom ones { + package TestCustomAttrs; + my $modify_invoked; sub MODIFY_CODE_ATTRIBUTES @@ -41,13 +43,23 @@ my ( $pkg, $sub, $attr ) = @_; $modify_invoked++; - is( $attr, "MyCustomAttribute(value here)", 'MODIFY_CODE_ATTRIBUTES takes attr' ); + ::is( $attr, "MyCustomAttribute(value here)", 'MODIFY_CODE_ATTRIBUTES takes attr' ); return (); } async sub is_attributed :MyCustomAttribute(value here) { } - ok( $modify_invoked, 'MODIFY_CODE_ATTRIBUTES invoked' ); + ::ok( $modify_invoked, 'MODIFY_CODE_ATTRIBUTES invoked' ); +} + +# RT131571 +{ + ok( defined eval q{ + use experimental 'signatures'; + async sub func :method ($self, @args) { } + 1; + }, 'signatures do not leak into attributes (RT131571)' ) or + diag( "Error was $@" ); } done_testing;


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.