Closed
Bug 1297756
Opened 9 years ago
Closed 9 years ago
[WebIDL] Cannot specify default value for union type with enumeration as member
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
mozilla51
| Tracking | Status | |
|---|---|---|
| firefox51 | --- | fixed |
People
(Reporter: botond, Assigned: bzbarsky)
References
Details
Attachments
(2 files, 1 obsolete file)
|
20.52 KB,
patch
|
nika
:
review+
|
Details | Diff | Splinter Review |
|
3.87 KB,
patch
|
nika
:
review+
|
Details | Diff | Splinter Review |
The following webidl:
enum Auto { "auto" };
dictionary D {
(double or Auto) foo = "auto";
}
fails to compile for me, with the following stack trace:
0:07.43 File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
0:07.44 "__main__", fname, loader, pkg_name)
0:07.44 File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
0:07.44 exec code in run_globals
0:07.44 File "/home/botond/dev/mozilla/central/python/mozbuild/mozbuild/action/webidl.py", line 19, in <module>
0:07.44 sys.exit(main(sys.argv[1:]))
0:07.44 File "/home/botond/dev/mozilla/central/python/mozbuild/mozbuild/action/webidl.py", line 15, in main
0:07.44 manager.generate_build_files()
0:07.44 File "/home/botond/dev/mozilla/central/dom/bindings/mozwebidlcodegen/__init__.py", line 271, in generate_build_files
0:07.44 written, deps = self._generate_build_files_for_webidl(filename)
0:07.44 File "/home/botond/dev/mozilla/central/dom/bindings/mozwebidlcodegen/__init__.py", line 477, in _generate_build_files_for_webidl
0:07.44 root = CGBindingRoot(self._config, binding_stem, filename)
0:07.44 File "/home/botond/dev/mozilla/central/dom/bindings/Codegen.py", line 13423, in __init__
0:07.44 cgthings.append(CGDictionary(t, config))
0:07.44 File "/home/botond/dev/mozilla/central/dom/bindings/Codegen.py", line 12202, in __init__
0:07.44 for member in dictionary.members]
0:07.44 File "/home/botond/dev/mozilla/central/dom/bindings/Codegen.py", line 5010, in getJSToNativeConversionInfo
0:07.44 defaultValue, "%s.SetStringData" % unionArgumentObj) +
0:07.44 File "/home/botond/dev/mozilla/central/dom/bindings/Codegen.py", line 4243, in handleDefaultStringValue
0:07.44 assert defaultValue.type.isDOMString()
0:07.44 AssertionError
:bz tells me this should work per spec.
| Assignee | ||
Comment 1•9 years ago
|
||
Attachment #8784987 -
Flags: review?(michael)
| Assignee | ||
Updated•9 years ago
|
Assignee: nobody → bzbarsky
Status: NEW → ASSIGNED
| Assignee | ||
Comment 2•9 years ago
|
||
Attachment #8784988 -
Flags: review?(michael)
Comment 3•9 years ago
|
||
Comment on attachment 8784987 [details] [diff] [review]
part 1. Improve the exception thrown when an invalid default value (right type but wrong value) is used for a union
Review of attachment 8784987 [details] [diff] [review]:
-----------------------------------------------------------------
::: dom/bindings/parser/WebIDL.py
@@ +3342,5 @@
> + # exception, because those are specific "coercion failed for
> + # reason X" exceptions.
> + if (isinstance(e, WebIDLError) and
> + e.message != ("Cannot coerce type %s to type %s." %
> + (self.type, subtype))):
This is pretty gross. If you want to do this string comparison, at least add a comment where this exception is thrown telling people who edit that message that they need to edit the message here too. Right now, if someone was to change that message without changing this one, the fix made by this patch would regress without anyone even noticing.
I think that I would prefer a new optional keyword argument in `WebIDLError.__init__` like "basic_coercion = false". The place where the error is thrown would explicitly set "basic_coercion = true", and we could just check `isinstance(e, WebIDLError) and e.basic_coercion` instead. It seems less fragile.
Attachment #8784987 -
Flags: review?(michael) → review-
| Assignee | ||
Comment 4•9 years ago
|
||
Good point. I don't think we want to add more noise to WebIDLError for this, but we can just subclass it.
Attachment #8784997 -
Flags: review?(michael)
| Assignee | ||
Updated•9 years ago
|
Attachment #8784987 -
Attachment is obsolete: true
Updated•9 years ago
|
Attachment #8784997 -
Flags: review?(michael) → review+
Updated•9 years ago
|
Attachment #8784988 -
Flags: review?(michael) → review+
Pushed by bzbarsky@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/07ec239ed9a4
part 1. Improve the exception thrown when an invalid default value (right type but wrong value) is used for a union. r=mystor
https://hg.mozilla.org/integration/mozilla-inbound/rev/32c64469a9c7
part 2. Allow specifying a default value for a union containing an enum. r=mystor
Comment 6•9 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/07ec239ed9a4
https://hg.mozilla.org/mozilla-central/rev/32c64469a9c7
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla51
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•