Skip to content

n-at-a-time foreach does not print a warning about odd-sized list #20760

Closed
@leonerd

Description

@leonerd

When assigning to a hash, an even-sized list is required. If an odd-sized list is presented, perl prints a warning:

my %h = (1, 2, 3);
Odd number of elements in hash assignment at (eval 7) line 1.

The new n-at-a-time foreach syntax never gives a warning in similar circumstances:

use experimental 'for_list'; foreach my ($k, $v) (1,2,3) {}
# no warning

Perhaps it should? It can't be worded quite the same way, because "odd vs even" is only a useful concept for n=2. But perhaps some wording such as:

Insufficient elements for final bundle of foreach list at ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Closable?We might be able to close this ticket, but we need to check with the reporter

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions