w3c/webidl2.js

Validate unique dictionary members (including inheritance)

foolip opened this issue · 4 comments

https://heycam.github.io/webidl/#idl-dictionaries says:

The identifier of a dictionary member must not be the same as that of another dictionary member defined on the dictionary or on that dictionary’s inherited dictionaries.

I tried if webidl2.js would catch such errors but it seems like not:

const { parse, validate } = require("webidl2");
const ast = parse(`dictionary A { any m; }; dictionary B : A { object m; };`);
const validations = validate(ast); // returns []

It actually looks like duplicating the member name on a single dictionary is also not validated for.

I wrote up a quick check for this locally (in webref) but to my surprise there doesn't seem to be any duplicate member names currently.

Yeah, the current name check only applies for parent types, not members. Something to be done later.

I strongly feel that the implementation here will share the core logic with #584, but not something to worry about for now.