Dictionary members should not allow [TreatNullAs] or [TreatUndefinedAs] annotations

RESOLVED FIXED in mozilla16

Status

()

Core
DOM
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: bz, Assigned: bz)

Tracking

unspecified
mozilla16
x86
Mac OS X
Points:
---
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

Spec says so.
Honestly, unless this is really easy to implement in the parser (and it's not clear that it would be), I don't think we should bother.
Created attachment 636473 [details] [diff] [review]
Don't allow [TreatNullAs] or [TreatUndefinedAs] on dictionary members.
Attachment #636473 - Flags: review?(justin.lebar+bug)
See above: pretty trivial to implement, imo.
Comment on attachment 636473 [details] [diff] [review]
Don't allow [TreatNullAs] or [TreatUndefinedAs] on dictionary members.

> class IDLArgument(IDLObjectWithIdentifier):
>-    def __init__(self, location, identifier, type, optional=False, defaultValue=None, variadic=False):
>+    def __init__(self, location, identifier, type, optional=False, defaultValue=None, variadic=False, dictionaryMember=False):
>         IDLObjectWithIdentifier.__init__(self, location, None, identifier)
> 
>         assert isinstance(type, IDLType)
>         self.type = type
> 
>         if defaultValue:
>             defaultValue = defaultValue.coerceToType(type, location)
>             assert defaultValue
> 
>         self.optional = optional
>         self.defaultValue = defaultValue
>         self.variadic = variadic
>+        self.dictionaryMember = dictionaryMember
> 
>         assert not variadic or optional
> 
>     def addExtendedAttributes(self, attrs):
>+        if self.dictionaryMember:
>+            for (attr, value) in attrs:
>+                if attr == "TreatUndefinedAs":
>+                    raise WebIDLError("[TreatUndefinedAs] is not allowed for "
>+                                      "dictionary members", [self.location])
>+                elif attr == "TreatNullAs":
>+                    raise WebIDLError("[TreatNullAs] is not allowed for "
>+                                      "dictionary members", [self.location])

This could be just |if 'TreatUndefinedAs' in attrs| and so on.
Attachment #636473 - Flags: review?(justin.lebar+bug) → review+
> This could be just |if 'TreatUndefinedAs' in attrs| and so on.

Attrs is a list of tuples, so I'm not sure it could.
https://hg.mozilla.org/integration/mozilla-inbound/rev/41412974ed77
Flags: in-testsuite+
Target Milestone: --- → mozilla16
https://hg.mozilla.org/mozilla-central/rev/41412974ed77
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.