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

Friendlier error message for invalid indices #221

Open
copumpkin opened this issue Jul 22, 2016 · 4 comments
Open

Friendlier error message for invalid indices #221

copumpkin opened this issue Jul 22, 2016 · 4 comments

Comments

@copumpkin
Copy link

For example, I got:

RUNTIME ERROR: Array index must be number, got string.

It would be easier to track down what was wrong if it told me what unexpected string it got

@sparkprime
Copy link
Contributor

I agree, but out of interest was the line/column accurate?

@copumpkin
Copy link
Author

Argh, I lost the original error and can't remember what caused it now. Will comment again if I run into it again.

@copumpkin
Copy link
Author

copumpkin commented Jul 24, 2016

Aha, I got it again, and the location was correct but a little confusing because I was looking for an array index. The actual culprit was (equivalent to):

local foo = [1,2,3];
foo.hello

It presumably happens because the dot notation gets desugared into square brackets, which mean that we end up with foo["hello"].

@sparkprime
Copy link
Contributor

It'd be good for it to remember the fact that this started off life as a ".foo" and print a different error message in that case. However what you originally proposed is simpler and probably good enough.

sbarzowski added a commit to sbarzowski/jsonnet that referenced this issue Jun 10, 2024
People use these operators in tight loops, without even
thinking about it, and it's previous implementation required
multiple object lookups (std.), string comparisons (for types)
and multiple jsonnet function calls.

This change introduces builtin, efficient implementation.
It results in ~3x speedup in strContains benchmark that
Angus provided on Slack.

Additional benefit is that equals/primitiveEquals distinction
is now obsolete, which made things simpler for everyone.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants