Skip to content

At-pos/at-key/zen slices hypered over empty List/Array crash #2133

Open
@zoffixznet

Description

These work:

m: dd (<a b>,)»[]
rakudo-moar a71e370bb: OUTPUT: «(("a", "b"),)␤»
m: dd ({:42foo},)»{}
rakudo-moar a71e370bb: OUTPUT: «({:foo(42)},)␤»
m: my @a = 42; dd @a»[]
 rakudo-moar a71e370bb: OUTPUT: «(42,)␤»
m: my @a = {:42foo},; dd @a»{} 
rakudo-moar a71e370bb: OUTPUT: «({:foo(42)},)␤»

But if the List/Array is empty, they crash:

rakudo-moar a71e370bb: OUTPUT: «This type (Scalar) does not support elems␤  in block <unit> at <tmp> line 1␤␤»
m: my @a; @a»[]                                                                
rakudo-moar a71e370bb: OUTPUT: «This type (Mu) does not support elems␤  in block <unit> at <tmp> line 1␤␤»
m: dd ()»{}                                                                                                                                          │
rakudo-moar a71e370bb: OUTPUT: «This type (Scalar) does not support elems␤  in block <unit> at <tmp> line 1␤␤»
m: my @a; @a»{}
rakudo-moar a71e370bb: OUTPUT: «This type (Mu) does not support elems␤  in block <unit> at <tmp> line

Happens with regular at-key/at-pos instead of zen slices as well:

m: my @a; @a».[1]
rakudo-moar a71e370bb: OUTPUT: «This type (Mu) does not support elems␤  in block <unit> at <tmp> line 1␤␤»

Metadata

Assignees

No one assigned

    Labels

    data typesArrays, lists, hashes, pair objects, etc.tests neededIssue is generally resolved but tests were not written yet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions