-
Notifications
You must be signed in to change notification settings - Fork 72
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
"Extra args dropped" was too lenient. Throw error instead #1888
Comments
I have been on the other side of that coin, where I would have gotten stuck in a bad situation had the method not allowed extra arguments. I'd argue that such programmer errors do not need to result in runtime errors, but that we need typing inference to work sufficiently to bring up these errors. |
The current example remains a good test case. Given the mistake that was made, to reliably recover from this mistake, we must not allow erroneous cases to silently do the wrong thing. As for reliable help from static types, I remain open to the possibility. Unlike TS in general, the TS types inferred from guards and patterns can be (and probably will be) sound, so there's hope. But I'll proceed with this "throw error" plan until I understand how some alternative works reliably. |
Agree. However I think static type checking is sufficient noise (and doesn't risk runtime breakage).
I suppose we could throw for now and relax if warranted, but we'd be risking compatibility pain that @mhofman brings up. Produce static type for guards is not a research problem, just a matter of prioritization. |
What I still don't understand is how sound static types for guards solves this problem.
Examples would help! |
Here's an example of how static types would alert. It acknowledges the peril of a static type not matching the runtime type, and thus not getting any error. As of now I'm convinced that it's better to throw. Maybe @mhofman has more/better examples. |
How is a static type error that is more strict than runtime check a hazard?
A few months ago I walked @markm through what motivated me (and how I discovered the current implementations was too lax): |
Edit: More precisely, the vat code accepts a new optional parameter |
The hazard I was referring to was:
|
Right, and that is the exact behavior that my branch is (ab)using. |
At #1764 I raise three alternatives
At #1765 I implemented and merged the third option. Experience since then has shown that this behavior is too lenient, in that it is still too likely to mask programmer bugs.
Rather, we need to implement/enforce the first option, where unexpected extra args cause an error. Any method that does want to be tolerant of extra args would them need to say so explicitly with a
.rest(M.any())
.We need to explore the consequences with any customers that may have accidentally written code that depends on the current too-lenient behavior, so that their interfaces become more explicit and thereby enforce stricter input validation.
The text was updated successfully, but these errors were encountered: