-
Notifications
You must be signed in to change notification settings - Fork 161
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
Detect whether a dictionary member was set by default or not #1300
Comments
How is In any event, if an implementation wanted to warn for this they already can. They'd just implement the defaulting outside of IDL. |
It would be very surprising to me to receive a warning when making use of a feature that’s seemingly been deliberately designed to improve developer ergonomics. It also would seem arbitrary to single out default dictionary member values without also warning for default argument values; they are two realizations of the same concept. |
This CL adds a DevTools console warning when a GPUBlendComponent is partially specified. Even though those have good default values, it is still useful to warn developers about it. I've filed WebIDL issue at whatwg/webidl#1300 to see if we can get WebIDL to change their behavior to not alter our IDL files. Bug: dawn:1785 Change-Id: I234419108cb92854d886e64f7b30c0fce173c5e6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4481266 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Fr <beaufort.francois@gmail.com> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Cr-Commit-Position: refs/heads/main@{#1139124}
It would be nice if WebIDL would provide a way to know whether a dictionary member was set by default or not.
dictionary MyDictionary { required boolean myRequiredMember; boolean myOptionalMember = false; };
In that case,
myOptionalMember
could befalse
because it was either set explicitly by developer with{ myRequiredMember: true, myOptionalMember: false }
or because it was not with{ myRequiredMember: true }
.Having a way to detect this would allow implementations to warn developers that a dictionary was partially specified which may result in unexpected behaviour. For instance,
{ myRequiredMember: true, myOptionalMemberWithTypo: true }
would setmyOptionalMember
tofalse
.Some would argue that if it's the case dictionary members should be declared
required
. I'm not sure about it. Providing default values is good but typos exist. I'd like to see efforts on that front.The text was updated successfully, but these errors were encountered: