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

Should report error for using duplicate names #77

Closed
vivekgalatage opened this issue Aug 9, 2017 · 3 comments
Closed

Should report error for using duplicate names #77

vivekgalatage opened this issue Aug 9, 2017 · 3 comments

Comments

@vivekgalatage
Copy link

Consider the following example idl:

typedef int Test;

interface Test {
  void foo();
};

The generated output is as

[
    {
        "extAttrs": [],
        "idlType": {
            "generic": null,
            "idlType": "int",
            "nullable": false,
            "sequence": false,
            "union": false
        },
        "name": "Test",
        "type": "typedef"
    },
    {
        "extAttrs": [],
        "inheritance": null,
        "members": [
            {
                "arguments": [],
                "creator": false,
                "deleter": false,
                "extAttrs": [],
                "getter": false,
                "idlType": {
                    "generic": null,
                    "idlType": "void",
                    "nullable": false,
                    "sequence": false,
                    "union": false
                },
                "legacycaller": false,
                "name": "foo",
                "setter": false,
                "static": false,
                "stringifier": false,
                "type": "operation"
            }
        ],
        "name": "Test",
        "partial": false,
        "type": "interface"
    }
]

In this case, the name Test is used twice: once for the interface and once for the typedef.

Should the library report this as an error?

@marcoscaceres
Copy link
Member

It's a tough call because IDL fragments are, more often then not, parsed independently - so this would have limited value to some applications (e.g., in ReSpec).

However, in cases where lots of fragments are parsed at once (and it would be a nice feature for validation/linting), thus I can certainly see the utility.

Having said that, does the IDL spec forbid duplicate identifiers even when different types? (I guess it probably should, just not sure).

@TimothyGu
Copy link
Member

Yes it does. https://heycam.github.io/webidl/#idl-names

Within the set of IDL fragments that a given implementation supports, the identifier of every interface, namespace, dictionary, enumeration, callback function and typedef must not be the same as the identifier of any other interface, namespace, dictionary, enumeration, callback function or typedef.

@marcoscaceres
Copy link
Member

Ok, thanks for confirming @TimothyGu.

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

No branches or pull requests

3 participants