Commit a67e8bcc authored by Boris Zbarsky's avatar Boris Zbarsky
Browse files

Bug 1531623. Fix webidl identifier conflicts involving typedefs to produce...

Bug 1531623.  Fix webidl identifier conflicts involving typedefs to produce saner exceptions.  r=qdot

Differential Revision: https://phabricator.services.mozilla.com/D21647

--HG--
extra : moz-landing-system : lando
parent eedd09df
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -2789,9 +2789,11 @@ class IDLTypedefType(IDLType):

class IDLTypedef(IDLObjectWithIdentifier):
    def __init__(self, location, parentScope, innerType, name):
        # Set self.innerType first, because IDLObjectWithIdentifier.__init__
        # will call our __str__, which wants to use it.
        self.innerType = innerType
        identifier = IDLUnresolvedIdentifier(location, name)
        IDLObjectWithIdentifier.__init__(self, location, parentScope, identifier)
        self.innerType = innerType

    def __str__(self):
        return "Typedef %s %s" % (self.identifier.name, self.innerType)
+16 −0
Original line number Diff line number Diff line
def WebIDLTest(parser, harness):
    exception = None
    try:
        parser.parse(
            """
            typedef long foo;
            typedef long foo;
            """)

        results = parser.finish()
    except Exception as e:
        exception = e

    harness.ok(exception, "Should have thrown.")
    harness.ok("Multiple unresolvable definitions of identifier 'foo'" in str(exception),
               "Should have a sane exception message")