Skip to content

Commit b3bf39a

Browse files
Remove size(bytes) override: built-in already returns int64
The C++ CEL runtime's size(bytes) returns int64, not uint64, so "this.size() == 4" works with the built-in _==_(int64, int64). Adding a size(bytes)->int64 overload caused an overload signature collision with the existing bytes_size built-in.
1 parent b45f69c commit b3bf39a

File tree

1 file changed

+0
-18
lines changed

1 file changed

+0
-18
lines changed

protovalidate/internal/extra_func.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1778,24 +1778,6 @@ def make_extra_funcs() -> cel.CelExtension:
17781778
)
17791779
],
17801780
),
1781-
# Override size(bytes) -> int64 so that comparisons like "this.size() == 4"
1782-
# use the built-in _==_(int64, int64) operator. The C++ CEL runtime's built-in
1783-
# size(bytes) returns uint64, but integer literals (e.g. 4) are int64, causing
1784-
# "this.size() == 4" to always be false due to strict type checking.
1785-
# Extension function FunctionDecls add overloads without replacing other
1786-
# parameter-type variants, so size(string)/size(list)/size(map) are unaffected.
1787-
cel.FunctionDecl(
1788-
"size",
1789-
[
1790-
cel.Overload(
1791-
"size_bytes_int",
1792-
return_type=cel.Type.INT,
1793-
parameters=[cel.Type.BYTES],
1794-
is_member=True,
1795-
impl=lambda b: len(b),
1796-
),
1797-
],
1798-
),
17991781
# Cross-type int/uint modulo overload.
18001782
# CEL predefined rules for uint types use uint literals (e.g. "this % 2u == 0u"),
18011783
# but Python int values are mapped to CEL int64. The result is uint64 so that

0 commit comments

Comments
 (0)