[whatwg/webidl] Seeking clarification on whether unioning promises and callbacks is allowed (Issue #1278)

While trying to make some IDL updates to the ClipboardItem constructor in Chromium (https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/modules/clipboard/clipboard_item.idl), we discovered that the Chromium IDL compiler failed to union a promise and callback, or even just multiple promises, together. We tried a few other cases where we unioned promises and/or callbacks with other types, and those seemed to work. Below is a list of what did work and what didn't.

typedef Promise<Blob> ClipboardBlobPromise;
typedef Promise<DOMString> ClipboardStringPromise;
callback ClipboardBlobCallback = Blob();
callback ClipboardStringCallback = DOMString();

typedef (Blob or DOMString) ClipboardItemData;    // works
typedef (ClipboardBlobPromise or DOMString) ClipboardItemData;    // works
typedef (Blob or ClipboardStringPromise) ClipboardItemData;    // works
**typedef (ClipboardBlobPromise or ClipboardStringPromise) ClipboardItemData;    // does not work**
typedef (Blob or ClipboardStringCallback);  // works
typedef (ClipboardBlobCallback or DOMString);  // works
typedef (ClipboardBlobCallback or ClipboardStringCallback);  // works
**typedef (ClipboardBlobPromise or ClipboardBlobCallback);  // does not work**

constructor(record<DOMString, ClipboardItemData> items);

Based on the above examples that do work, as well as reading through the WebIDL spec, it does not look like there should be any limitations on callback function types or promise types participating in unions. Does this sound like a bug in the Chromium WebIDL compiler, or is there anything in the spec that should prevent such cases from working?

cc: @snianu, @anaskim

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/webidl/issues/1278
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/webidl/issues/1278@github.com>

Received on Thursday, 9 March 2023 09:25:50 UTC