wasm-bindgen icon indicating copy to clipboard operation
wasm-bindgen copied to clipboard

Mark some set_* fns as potentially throwing.

Open richard-uk1 opened this issue 3 years ago • 5 comments

Make attributes marked [SetterThrows] use a set_* function that returns a Result. Currently webidl only looks for a [Throws] attribute.

I found this problem while writing an indexed DB wrapper. The function web_sys::IdbObjectStore::set_name should return a Result, because setting the name can go wrong in a number of ways. When I looked at the IDL files, the attribute had a [SetterThrows] mark rather than the more general [Throws].

richard-uk1 avatar Apr 04 '22 14:04 richard-uk1

Ready for review

richard-uk1 avatar Apr 05 '22 10:04 richard-uk1

This naively looks like a breaking change which is something I don't want to commit to. Is there a reason though that this won't be an issue in practice?

alexcrichton avatar Apr 05 '22 14:04 alexcrichton

It is a breaking change, but currently the generated code is incorrect (some attribute setters can throw and agent caught by web_sys). Do you allow breaking changes to correct errors?

On Tue, 5 Apr 2022, 15:55 Alex Crichton, @.***> wrote:

This naively looks like a breaking change which is something I don't want to commit to. Is there a reason though that this won't be an issue in practice?

— Reply to this email directly, view it on GitHub https://github.com/rustwasm/wasm-bindgen/pull/2852#issuecomment-1088817891, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKT4XQVOPVPO2JB4X4R2XLVDRH55ANCNFSM5SPYL6DQ . You are receiving this because you authored the thread.Message ID: @.***>

richard-uk1 avatar Apr 05 '22 16:04 richard-uk1

Sorry I'm not merging breaking changes at this time because I'm not personally prepared to deal with the fallout. I wish I had a better answer for you but I do not at this time.

alexcrichton avatar Apr 06 '22 15:04 alexcrichton

Ok no worries shall I leave the pr open?

On Wed, 6 Apr 2022, 16:42 Alex Crichton, @.***> wrote:

Sorry I'm not merging breaking changes at this time because I'm not personally prepared to deal with the fallout. I wish I had a better answer for you but I do not at this time.

— Reply to this email directly, view it on GitHub https://github.com/rustwasm/wasm-bindgen/pull/2852#issuecomment-1090419969, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKT4XSYVRIO2XBC4W4X3FDVDWWGZANCNFSM5SPYL6DQ . You are receiving this because you authored the thread.Message ID: @.***>

richard-uk1 avatar Apr 06 '22 16:04 richard-uk1