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

Inconsistent handling of too-large array index between match variables and regular arrays #10

Open
MasterDuke17 opened this issue Apr 13, 2019 · 3 comments
Labels
language Changes to the Raku Programming Language

Comments

@MasterDuke17
Copy link

say $/[9999999999999999999999999999999999999999999999] gives «Nil␤»
my @a = 1,2; say @a[9999999999999999999999999999999999999999999999] gives «(exit code 1) Cannot unbox 153 bit wide bigint into native integer␤ in block <unit> at /tmp/ldjuzMCrIl line 1␤␤»

I have two versions of a patch for the Match variable case, one throws X::Syntax::Variable::Match (could be a different type though), the other dies with ===SORRY!=== Cannot unbox 203 bit wide bigint into native integer.

Thoughts on what's best?

@AlexDaniel AlexDaniel added the language Changes to the Raku Programming Language label Apr 13, 2019
@jnthn
Copy link
Contributor

jnthn commented Apr 16, 2019

It's so unlikely to happen in real code that I'd just leave it to be a normal runtime error thrown by array indexing (which should be achievable by code-generating it as a normal Perl 6 integer constant, meaning a big integer will be used if needed).

If it is done at compile time, then Any ===SORRY!=== error should include a line number and file name, and it should probably better indicate the program element that was out of range.

@AlexDaniel
Copy link
Member

It's so unlikely to happen in real code

What about EVAL? For example, can't it slip through relatively proper input validation? Something like “if X is an ascii number, and if all of the passed parameters are not bigger than half 100 bytes, then proceed”.

@jnthn
Copy link
Contributor

jnthn commented Apr 24, 2019

What about EVAL? For example, can't it slip through relatively proper input validation?

Yes, but even then, I don't think the effort of a compile-time error for it is worthwhile, so long as the runtime error (out of range value for array indexing) is decent.

@lizmat lizmat unassigned jnthn Oct 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language Changes to the Raku Programming Language
Projects
None yet
Development

No branches or pull requests

3 participants