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

Failure on servo's WebGLContextEvent.webidl #40

Open
JMLX42 opened this issue Aug 11, 2020 · 2 comments
Open

Failure on servo's WebGLContextEvent.webidl #40

JMLX42 opened this issue Aug 11, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@JMLX42
Copy link

JMLX42 commented Aug 11, 2020

Describe the Bug

The parsing of WebGLContextEvent.webidl:

* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */

// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15
[Exposed=Window]
interface WebGLContextEvent : Event {
    [Throws] constructor(DOMString type, optional WebGLContextEventInit eventInit = {});
    readonly attribute DOMString statusMessage;
};

// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15
dictionary WebGLContextEventInit : EventInit {
    DOMString statusMessage;
};

fails the following error:

[src/main.rs:29] parsed = Err(
    Failure(
        Code(
            CompleteStr(
                "/* This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/. */\n\n// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15\n[Exposed=Window]\ninterface WebGLContextEvent : Event {\n    [Throws] constructor(DOMString type, optional WebGLContextEventInit eventInit = {});\n    readonly attribute DOMString statusMessage;\n};\n\n// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15\ndictionary WebGLContextEventInit : EventInit {\n    DOMString statusMessage;\n};\n",
            ),
            Custom(
                0,
            ),
        ),
    ),
)

Steps to Reproduce

let parsed = weedle::parse("
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15
[Exposed=Window]
interface WebGLContextEvent : Event {
    [Throws] constructor(DOMString type, optional WebGLContextEventInit eventInit = {});
    readonly attribute DOMString statusMessage;
};

// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15
dictionary WebGLContextEventInit : EventInit {
    DOMString statusMessage;
};
");

The problem appears to be the following content: optional WebGLContextEventInit eventInit = {}. Removing the default value declaration to have optional WebGLContextEventInit eventInit makes the parsing work OK.

Expected Behavior

The WebIDL is parsed properly and the corresponding AST is returned.

@JMLX42 JMLX42 added the bug Something isn't working label Aug 11, 2020
@JMLX42
Copy link
Author

JMLX42 commented Aug 11, 2020

Replacing:

    [Throws] constructor(DOMString type, optional WebGLContextEventInit eventInit = {});

with:

    [Throws] constructor(DOMString type, optional WebGLContextEventInit eventInit = 0);

make the parsing works. My understanding is that maybe {} is not a handled as a default value for args.

It looks like this part of the parsing is done here:

https://github.com/rustwasm/weedle/blob/master/src/argument.rs#L19

But I don't understand yet why 0 works but {} does not work.

@JMLX42
Copy link
Author

JMLX42 commented Aug 11, 2020

Default is defined in common.rs and relies on DefaultValue which is defined in literals.rs and does have a specific case for the empty dict initializer:

https://github.com/rustwasm/weedle/blob/master/src/literal.rs#L63

So it's still unclear why 0 works but not {}.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant