Skip to content

Failure on servo's WebGLContextEvent.webidl #40

@JMLX42

Description

@JMLX42

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions