Closed Bug 946897 Opened 8 years ago Closed 8 years ago

WebIDL emits unhelpful error message on interface name collisions

Categories

(Core :: DOM: Core & HTML, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla31

People

(Reporter: mikeh, Assigned: anilreddykatta)

References

Details

(Whiteboard: [mentor=jdm][lang=py][good first bug])

Attachments

(1 file, 2 obsolete files)

Found doing this:

--- X.webidl ---
callback Foo = void (DOMString foo);
interface Bar {
  [Throws]
  getFoo(optional Foo callback);
};

--- Y.webidl ---
interface Foo;
// ...

Emitted traceback and error:

Traceback (most recent call last):
  File "/home/mikeh/dev/mozilla/m-c/b2g-inbound/config/pythonpath.py", line 56, in <module>
    main(sys.argv[1:])
  File "/home/mikeh/dev/mozilla/m-c/b2g-inbound/config/pythonpath.py", line 48, in main
    execfile(script, frozenglobals)
  File "/home/mikeh/dev/mozilla/m-c/b2g-inbound/dom/bindings/GlobalGen.py", line 81, in <module>
    main()
  File "/home/mikeh/dev/mozilla/m-c/b2g-inbound/dom/bindings/GlobalGen.py", line 55, in main
    parser.parse(''.join(lines), fullPath)
  File "/home/mikeh/dev/mozilla/m-c/b2g-inbound/dom/bindings/parser/WebIDL.py", line 4811, in parse
    self._productions.extend(self.parser.parse(lexer=self.lexer,tracking=True))
  File "/home/mikeh/dev/mozilla/m-c/b2g-inbound/other-licenses/ply/ply/yacc.py", line 263, in parse
    return self.parseopt(input,lexer,debug,tracking,tokenfunc)
  File "/home/mikeh/dev/mozilla/m-c/b2g-inbound/other-licenses/ply/ply/yacc.py", line 710, in parseopt
    p.callable(pslice)
  File "/home/mikeh/dev/mozilla/m-c/b2g-inbound/dom/bindings/parser/WebIDL.py", line 3809, in p_CallbackRest
    identifier, p[3], p[5])
  File "/home/mikeh/dev/mozilla/m-c/b2g-inbound/dom/bindings/parser/WebIDL.py", line 2882, in __init__
    IDLObjectWithScope.__init__(self, location, parentScope, identifier)
  File "/home/mikeh/dev/mozilla/m-c/b2g-inbound/dom/bindings/parser/WebIDL.py", line 410, in __init__
    IDLObjectWithIdentifier.__init__(self, location, parentScope, identifier)
  File "/home/mikeh/dev/mozilla/m-c/b2g-inbound/dom/bindings/parser/WebIDL.py", line 362, in __init__
    self.resolve(parentScope)
  File "/home/mikeh/dev/mozilla/m-c/b2g-inbound/dom/bindings/parser/WebIDL.py", line 369, in resolve
    self.identifier.resolve(parentScope, self)
  File "/home/mikeh/dev/mozilla/m-c/b2g-inbound/dom/bindings/parser/WebIDL.py", line 343, in resolve
    scope.ensureUnique(self, object)
  File "/home/mikeh/dev/mozilla/m-c/b2g-inbound/dom/bindings/parser/WebIDL.py", line 250, in ensureUnique
    object)
  File "/home/mikeh/dev/mozilla/m-c/b2g-inbound/dom/bindings/parser/WebIDL.py", line 268, in resolveIdentifierConflict
    if originalObject.tag == IDLInterfaceMember.Tags.Method and \
AttributeError: 'IDLExternalInterface' object has no attribute 'tag'
I suspect a good way to improve this situation is to check for IDLExternalInterface in resolveIdentifierConflict and print out a better message.
Whiteboard: [mentor=jdm][lang=py][good first bug]
Assignee: nobody → anilreddykatta
can any tell me how to reproduce the issue?
can any tell me how to reproduce the issue?
anra_ka: see comment 0?
Printing extra information like identifier caused collision and respective location of files where it resides
Attachment #8346878 - Flags: review?(khuey)
What happens if it's the newObject that's the IDLExternalInterface?
Forgot to check whether newObjet or originalObject is instance of IDLExternalInterface
Attachment #8346878 - Attachment is obsolete: true
Attachment #8346878 - Flags: review?(khuey)
Attachment #8347041 - Flags: review?(khuey)
@Boris: I forgot to do that. Fixed that in latest patch..May be you can have a look
Yes, that looks much more plausible.  Are the two if bodies in fact identical?
yeah...I was about to correct that..place body of if loop inside one if where conditions for newObject and originalObject are 'OR'
Merged two if's into one
Attachment #8347041 - Attachment is obsolete: true
Attachment #8347041 - Flags: review?(khuey)
Attachment #8347050 - Flags: review?(khuey)
Comment on attachment 8347050 [details] [diff] [review]
bug946897_webidl_interface_name_collisions_updated.diff

Review of attachment 8347050 [details] [diff] [review]:
-----------------------------------------------------------------

I'm sorry it took me so long to get to this.  Thank you very much for the patch.  Please make these minor changes and then we can check it in.

::: dom/bindings/parser/WebIDL.py
@@ +259,5 @@
>          if isinstance(originalObject, IDLExternalInterface) and \
>             isinstance(newObject, IDLExternalInterface) and \
>             originalObject.identifier.name == newObject.identifier.name:
>              return originalObject
> +        

Please remove the extra whitespace on this line.

@@ +264,5 @@
> +        if isinstance(originalObject, IDLExternalInterface) or isinstance(newObject, IDLExternalInterface):
> +            raise WebIDLError(
> +                "Name collision between "
> +                "interface declarations for identifier '%s' at '%s' and '%s'"
> +                % (identifier.name, 

And what's at the end of this line.
Attachment #8347050 - Flags: review?(khuey) → review+
anra_ka, will you have a chance to make those changes?
Flags: needinfo?(anilreddykatta)
Boris: I am currently out of station. Is it possible for you to make those changes?
Flags: needinfo?(anilreddykatta)
Blocks: 879917
Flags: needinfo?(bzbarsky)
https://hg.mozilla.org/mozilla-central/rev/1f060244afe9
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla31
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.