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

Dispatching on native array types fails with optimization switched on #4090

Open
lizmat opened this issue Dec 5, 2020 · 3 comments
Open
Labels
data types Arrays, lists, hashes, pair objects, etc. native types anything related to signed or unsigned native ints, or num, or str

Comments

@lizmat
Copy link
Contributor

lizmat commented Dec 5, 2020

The Problem

sub foo(array::intarray \SELF) { dd }
my int @i = 1,2,3;
foo(@i);

Expected Behavior

sub foo(array::intarray \SELF)

Actual Behavior

===SORRY!=== Error while compiling 11
Calling foo(Positional[int]) will never work with declared signature (array::intarray \SELF)

Additional notes: running this code with --optimize=off, makes it work as expected. And since the optimizer is responsible for the "cannot ever dispatch" error, this feels like it is incorrectly deciding it will not be able to dispatch, whereas it clearly can.

Additional data-point: changing the call to: foo($@a) also makes it work, even with the optimization on. So perhaps it's because it doesn't realize that a native array is already an item?

@lizmat
Copy link
Contributor Author

lizmat commented Dec 5, 2020

It looks like in https://github.com/rakudo/rakudo/blob/master/src/Perl6/Optimizer.nqp#L2063 the call to nqp::p6trialbind returns -1.

@Altai-man
Copy link
Member

Is it something new?

@lizmat
Copy link
Contributor Author

lizmat commented Dec 5, 2020

No, it's probably something very old. It's just now that I've been able to golf it down :-)

@Altai-man Altai-man added data types Arrays, lists, hashes, pair objects, etc. native types anything related to signed or unsigned native ints, or num, or str labels Dec 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data types Arrays, lists, hashes, pair objects, etc. native types anything related to signed or unsigned native ints, or num, or str
Projects
None yet
Development

No branches or pull requests

2 participants