-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix return type of WebIDL indexing getters #1789
Fix return type of WebIDL indexing getters #1789
Conversation
Thanks for the PR! It's been awhile since I looked at this, so can you describe in the commits/PR message what this is doing? |
@alexcrichton I have updated the description of PR/commits. |
Thanks for this! The impact here seems pretty minimal actually so I think it might be reasonable for us to consider doing this in a point release, despite it being a breaking change. In terms of implementation though, could this be done not by looking for |
Thanks for the feedback!
Yes, and I have arrived at a much more compact solution: 53b0cd0
Precisely. I have updated the PR's description and implementation comments. |
Great! Mind doing an analysis again to produce a list of which APIs are changing? |
I have done an analysis as follows: 1) set up API signature dumping wasm-bindgen/crates/backend/src/codegen.rs Lines 1006 to 1012 in 74812bd
add {
let js_fn_name = format!("{}", &self.shim);
let rust_fn = quote! { #vis fn #rust_name(#me #(#arguments),*) };
let rust_fn_ret = quote! { #ret };
println!("analysis: | {} | {} | {} |", js_fn_name, rust_fn, rust_fn_ret);
} 2) collect API signature dumps
2.2) apply 53b0cd0 and 46dd0aa
3) print the changing APIs
|
Thanks for this! @fitzgen how do you feel landing this in a point release? While strictly a breaking change it seems like it's sort of hard to use right without this |
I feel OK about it, given that these are pretty niche APIs. It seems like it is worth the trade off. |
Ok, let's go ahead and merge this then. If issues come up we can yank, revert, and publish a new version, and then schedule it for the next breaking wasm-bindgen release. |
This PR is to update the return signatures of WebIDL indexing getters. All indexing getters will return optional values unless marked by
[Throws]
in their WebIDL definitions.I summarize the impact of this change in the list below. As a result, 14 indexing getters with originally unwrapped return type
T
(non-highlighted in 3rd column) will returnOption<T>
instead.Since this is a breaking change, I am including some commits that deal with affected examples as well. It turned out that I found only the
todomvc
example (50fbb5c).Motivation
In #1756, we have observed the situations where indexing getters (such as
__widl_f_get_DOMStringMap
and__widl_f_get_CSSStyleDeclaration
) can returnundefined
that breaks our assumptions based on their WebIDL definitions, leading to unrecoverable runtime exceptions. Following @Pauan 's advice, this PR is aimed at fixing the problem by updating the return signatures of indexing getters.