From 18f039543aaac5cf52666433ece5697dcc6b100d Mon Sep 17 00:00:00 2001 From: Moonchild Date: Fri, 16 Aug 2024 14:31:51 +0200 Subject: [PATCH] Issue #1810 - Allow superfluous [LenientFloat] extended attributes. This changes the way the extended attribute [LenientFloat] behaves, so that overloading functions can match extended attributes while not having restricted float type arguments themselves. --- dom/bindings/parser/WebIDL.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/dom/bindings/parser/WebIDL.py b/dom/bindings/parser/WebIDL.py index 0aa3afa4e8..5c6b6eed32 100644 --- a/dom/bindings/parser/WebIDL.py +++ b/dom/bindings/parser/WebIDL.py @@ -4888,6 +4888,16 @@ class IDLMethod(IDLInterfaceMember, IDLScope): raise WebIDLError("StaticClassOverride can be applied to static" " methods on JS-implemented classes only.", [self.location]) + if self.getExtendedAttribute("LenientFloat"): + assert len(self.signatures()) >= 1 + found = False + for sig in self.signatures(): + if any(arg.type.includesRestrictedFloat() for arg in sig[1]): + found = True + if not found: + raise WebIDLError("[LenientFloat] used on an operation with no " + "restricted float type arguments", + [self.location]) def overloadsForArgCount(self, argc): return [overload for overload in self._overloads if @@ -4966,10 +4976,6 @@ class IDLMethod(IDLInterfaceMember, IDLScope): if not sig[0].isVoid(): raise WebIDLError("[LenientFloat] used on a non-void method", [attr.location, self.location]) - if not any(arg.type.includesRestrictedFloat() for arg in sig[1]): - raise WebIDLError("[LenientFloat] used on an operation with no " - "restricted float type arguments", - [attr.location, self.location]) elif identifier == "Exposed": convertExposedAttrToGlobalNameSet(attr, self._exposureGlobalNames) elif (identifier == "CrossOriginCallable" or