Subject: | Possible keyword expansion bug |
I suspect that this is a bug in the way keywords are expanded... unless it is a misunderstanding on my part about how they are intended to behave. When declaring a keyword that expands into part of an expression, the debug output shows it being expanded correctly, but the expanded form does not appear to have replaced the keyword in the final code. Note that this happens not only with the example below, but with an array (e.g `keyword foo() {return '[1,2,3]'}`) and a simple string as well (`keyword foo() {return '"hello world"'}`).
$ cat scratch.pl
use Keyword::Declare {debug => 1};
keyword foo () { return q{('foo' => 'bar')};}
my %param = foo;
$ perl scratch.pl
#####################################################
### Installed keyword macro at scratch.pl line 3:
###
###foo
###
#####################################################
#####################################################
### Keyword macro defined at scratch.pl line 3:
###
### foo
###
### Converted code at scratch.pl line 7:
###
### foo
###
### Into:
###
### ('foo' => 'bar')
###
#####################################################
syntax error at scratch.pl line 6, near "= foo"
Execution of scratch.pl aborted due to compilation errors.