Chromium Code Reviews
Description[Extensions Bindings] Consider argument type more in signature parsing
Right now, when parsing arguments, we look at whether or not an argument
matches the expected argument, and, if it does not and the argument is
optional, we advance to the next argument. This results in strange
error messages when in certain circumstances. For instance, consider a
signature:
optional object<prop: string>, optional function
If we pass {prop: 2} to this signature, we'd first compare against
the object parameter, find it doesn't match, and then advance to
comparing against the function argument. This resulted in an error
message focusing on the function argument, rather than the object
argument.
To address this, check the types of the arguments first. If the type
matches the expected type, assume that the argument is meant to match.
This way, when we see the first argument is an object, we parse it
against the object parameter and give appropriate errors.
This can potentially cause issues when there is an ambiguous signature
based on argument types (e.g., optional object, optional object, and
provided a single argument - which object to match against?), but these
ambiguous signatures are already disallowed unless the API implements
custom handling.
BUG=653596
Review-Url: https://codereview.chromium.org/2947223003
Cr-Commit-Position: refs/heads/master@{#482118}
Committed: https://chromium.googlesource.com/chromium/src/+/d701d8e63d28192afbdbe9d0d65569a4b994fd51
Patch Set 1 #Patch Set 2 : . #
Total comments: 3
Patch Set 3 : rebase #
Messages
Total messages: 21 (15 generated)
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||