rakudo / rakudo

🦋 Rakudo – Raku on MoarVM, JVM, and JS
https://rakudo.org/
Artistic License 2.0
1.73k stars 374 forks source link

Semicolon-separated subscripting gives weird results instead of Whatever-currying #4995

Open 2colours opened 2 years ago

2colours commented 2 years ago

The Problem

Subscripts work for basic Whatever-currying - not with semilists, however. Since Whatever can be Positional-indexed but not Associative-indexed, two different but equally undesirable outcomes can be witnessed.

Expected Behavior

*[0;5] #WhateverCode.new *{'fej';'arc'} #WhateverCode.new

Actual Behavior

*[0;5] #Index out of range. Is: 5, should be in 0..0 - yes, *[0;0] succeeds and gives * *{'fej';'arc'} #Type Whatever does not support associative indexing.

Environment

2colours commented 2 years ago

The behavior is probably driven by syntax. Maybe it should be addressed in the RakuAST branch?

lizmat commented 2 years ago

I seem to recall @TimToady saying something about Whatever currying stopping when encountering a semi-colon. So maybe this behaviour is intentional.