If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

redundant typedefs give uninformative webidl parser error message

RESOLVED FIXED in mozilla26

Status

()

Core
DOM
RESOLVED FIXED
4 years ago
4 years ago

People

(Reporter: jib, Assigned: bz)

Tracking

Trunk
mozilla26
x86
Mac OS X
Points:
---
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

The following in a webidl file:

  typedef double Lalala;
  typedef double Lalala;

causes the parser to fail:

Traceback (most recent call last):
  File ".../config/pythonpath.py", line 56, in <module>
    main(sys.argv[1:])
  File ".../config/pythonpath.py", line 48, in main
    execfile(script, frozenglobals)
  File ".../dom/bindings/GlobalGen.py", line 78, in <module>
    main()
  File ".../dom/bindings/GlobalGen.py", line 55, in main
    parser.parse(''.join(lines), fullPath)
  File ".../dom/bindings/parser/WebIDL.py", line 4621, in parse
    self._productions.extend(self.parser.parse(lexer=self.lexer,tracking=True))
  File ".../other-licenses/ply/ply/yacc.py", line 263, in parse
    return self.parseopt(input,lexer,debug,tracking,tokenfunc)
  File ".../other-licenses/ply/ply/yacc.py", line 710, in parseopt
    p.callable(pslice)
  File ".../dom/bindings/parser/WebIDL.py", line 3634, in p_Typedef
    typedef.resolve(self.globalScope())
  File ".../dom/bindings/parser/WebIDL.py", line 368, in resolve
    self.identifier.resolve(parentScope, self)
  File ".../dom/bindings/parser/WebIDL.py", line 341, in resolve
    scope.ensureUnique(self, object)
  File ".../dom/bindings/parser/WebIDL.py", line 246, in ensureUnique
    assert object != self._dict[identifier.name]
AssertionError
make[6]: *** [ParserResults.pkl] Error 1
make[5]: *** [bindings_export] Error 2
make[4]: *** [export_tier_platform] Error 2
make[3]: *** [tier_platform] Error 2
make[2]: *** [default] Error 2
make[1]: *** [realbuild] Error 2
make: *** [build] Error 2

Instead we should silently ignore duplicate typedefs (like this one) and error on ones that try to redefine something.
More commonly, this problem also happens if you redefine typedefs from another file.
I wonder whether we should ignore duplicate ones or give a more informative error message....  It seems like a bug in the relevant specs if typedefs are duplicated.
Flags: needinfo?(cam)
Sorry for missing the needinfo here.

The Web IDL spec says:

  Within the set of IDL fragments that a given implementation supports, the
  identifier of every interface, dictionary, exception, enumeration, callback
  function and typedef MUST NOT be the same as the identifier of any other
  interface, dictionary, exception, enumeration, callback function or typedef

(oh, and it's missing a full stop there).  I think it would be best to keep this as an error, and maybe have a better error message.
Flags: needinfo?(cam)
Summary: redundant typedefs halt webidl parser → redundant typedefs give uninformative webidl parser error message
So this is really a problem with the custom __eq__ that typedefs have (which they have because they're IDLTypes).  It causes them to test equal even if the objects are different.
Created attachment 795829 [details] [diff] [review]
Give a better error message if the same name is typedeffed twice in WebIDL.   could also switch typedefs to using IDLWrapperType, but this seems like a smaller and still-sane change.
Attachment #795829 - Flags: review?(khuey)
Assignee: nobody → bzbarsky
Status: NEW → ASSIGNED
Whiteboard: [need review]
Attachment #795829 - Flags: review?(khuey) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/fd9ecdb7aa06
Flags: in-testsuite+
Whiteboard: [need review]
Target Milestone: --- → mozilla26

Comment 7

4 years ago
https://hg.mozilla.org/mozilla-central/rev/fd9ecdb7aa06
Status: ASSIGNED → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.