You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In that case, myOptionalMember could be false 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 set myOptionalMember to false.
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:
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.
aarongable
pushed a commit
to chromium/chromium
that referenced
this issue
May 3, 2023
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 <[email protected]>
Commit-Queue: Fr <[email protected]>
Reviewed-by: Kai Ninomiya <[email protected]>
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: