-
Notifications
You must be signed in to change notification settings - Fork 164
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
feat: Check types of values passed to native functions, prevent panics. #728
base: main
Are you sure you want to change the base?
feat: Check types of values passed to native functions, prevent panics. #728
Conversation
Maybe @sh0rez could take a look? Thanks. |
9d48bcb
to
45008be
Compare
Rebased against |
Previously, the native functions would panic if the type of the value wasn't right. Now, there is a bit of reflection to detect incorrect types and also to do the conversions to the types the function needs.
No-op functionality-wise.
e79c93a
to
a7082ad
Compare
Rebased against current HEAD (7345b9d) and improved a bit. Edit: The diff is now best viewed with changes in whitespace hidden :) |
Just to elaborate a bit on what this PR tries to achieve.
With
You'd get... With 0.26.0:
With this PR:
A stacktrace in 0.23.1 (which was around the time when I filed this PR):
|
Could this be a good fit for upstream go-jsonnet? Looks like a potential improvement for |
That's a good point. It'd have to be a bit more generic on the types side I guess. I'll prepare something and ask the go-jsonnet people... |
Previously, the native functions would panic if the type of the value
wasn't right. Now, there is a bit of reflection to detect incorrect
types and also to do the conversions to the types the function needs.