Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@a[-1;0]:exists returns True #2929

Open
HarmtH opened this issue May 26, 2019 · 2 comments
Open

@a[-1;0]:exists returns True #2929

HarmtH opened this issue May 26, 2019 · 2 comments

Comments

@HarmtH
Copy link

HarmtH commented May 26, 2019

The Problem

> my @a; my $neg=-1; say @a[$neg;0]:exists
True

Expected Behavior

It returns False

Environment

  • Operating system: Ubuntu 18.04
  • Compiler version (perl6 -v): This is Rakudo version 2018.11 built on MoarVM version 2018.11 implementing Perl 6.d.
@lizmat
Copy link
Contributor

lizmat commented May 28, 2019

Fixed with ca7408e9fa , tests added with Raku/roast@4e732c620b

@lizmat lizmat closed this as completed May 28, 2019
@HarmtH
Copy link
Author

HarmtH commented May 28, 2019

I was thinking a bit about this issue and about fix ca7408e9fa

Wouldn't the array-of-array notation still be broken?

my @a; my $neg=-1; say @a[$neg][0]:exists
True

I think the real issue is Failures 'exist'. Maybe Failures should behave more like Nil. As a Failure is a Nil, that would also make sense. Although I don't know what the language specs say about this.

Failure is a Nil is a Cool is an Any is a Mu

> Failure.new[0]:exists
True
> Nil.new[0]:exists
False
> Cool.new[0]:exists
True
> Any.new[0]:exists
True
> Mu.new[0]:exists
Type check failed in binding to parameter '<anon>'; expected Any but got Mu (Mu.new)
  in block <unit> at <unknown file> line 1

@lizmat lizmat reopened this May 29, 2019
@lizmat lizmat assigned lizmat and unassigned lizmat May 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants