[heycam/webidl] Mixins can lead to empty exposure sets in weird ways (#761)

Consider this IDL:
```
[Exposed=Window] interface Foo {};
[Exposed=Worker] interface mixin Bar { 
  readonly attribute long attr; 
};
Foo includes Bar;
```
If I read https://heycam.github.io/webidl/#Exposed correctly, this should result in `attr` having an empty exposure set on `Foo`.  In fact, the entire `includes` statement is pointless: given the exposure set of the mixin, it can't add anything to the interface.  This would be a little less obvious if it were written like so:
```
[Exposed=Window] interface Foo {};
interface mixin Bar { 
  [Exposed=Worker] 
  readonly attribute long attr; 
};
Foo includes Bar;
```
because then adding an un-annotated member to the mixin would cause it to be exposed on the interface, so that part would be OK, in theory.

If we're generally OK with this setup, we should still consider making that first snippet invalid, so people don't accidentally write it.

As a generalization of that, I'd actually prefer it if mixins had to explicitly say which globals they're OK being mixed into and if we required that the exposure set of a mixin had to be a superset of the exposure sets of the interfaces it's mixed into.  Members that shouldn't be exposed in all those would then have their own Exposed attributes or be in a `partial interface mixin` with an `Exposed` attribute...  I guess that's basically the behavior we get right now if the mixin does not specify `Exposed` at all, but it would be a bit more explicit...

@saschanaz @Ms2ger @tobie @domenic @annevk 

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

Received on Wednesday, 31 July 2019 21:06:05 UTC