Skip to content
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

Enable union types without interfaces in WebIDL #862

Merged
merged 2 commits into from
Sep 24, 2018

Conversation

alexcrichton
Copy link
Contributor

Bind them all as JsValue as that's the "least common ancestor" we can
work with. Fixes up one location in WebIDL where Option<JsValue>
arose as we haven't implemented that.

Closes #817

@alexcrichton alexcrichton requested a review from afdw September 21, 2018 00:36
@afdw
Copy link
Contributor

afdw commented Sep 21, 2018

I have previously implemented this with a simple check for unions in code that handles nullable types while converting them to syn types: if it is a nullable type with a union type inside it, then return IdlType::Any.to_syn_type(pos). This can save us from modifying WebIDL files (with a bit more complicated code logic though, but hopefully it will be only temporary).

@alexcrichton
Copy link
Contributor Author

I'd be fine either way, but I feel like that sort of check is quite complicated and would lean towards this solution since it only comes up in one location. Do you have the code though for what that looks like?

@afdw
Copy link
Contributor

afdw commented Sep 22, 2018

See here: 095f86f
I am OK with both ways too, I only meant that todo in code has less chance to be forgotten then one in a WebIDL file.

Bind them all as `JsValue` as that's the "least common ancestor" we can
work with. Fixes up one location in WebIDL where `Option<JsValue>`
arose as we haven't implemented that.

Closes rustwasm#817
@alexcrichton
Copy link
Contributor Author

Ah ok right! I've updated with a slight variant of that to just check for any JsValue coming out instead of specifically unions, and that should hopefully avoid some duplication

@alexcrichton alexcrichton merged commit c5d3ca9 into rustwasm:master Sep 24, 2018
@alexcrichton alexcrichton deleted the more-types branch September 24, 2018 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants