class X::Placeholder::Mainline is X::Placeholder::Block { }

Thrown when a placeholder variable is used in the mainline, i.e. outside of any explicit block.

For example


dies with

Cannot use placeholder parameter $^x outside of a sub or block

Note that this error can also occur when you think something is a block, but it really is a postcircumfix:<{ }>, for example

my %h;
say %h{ $^x };
#     ^^^^^^^  not a block, so $^x is part of the mainline