Align error handling in to_int with existing behavior of to_count

Previously `to_int` would silently ignore invalid inputs and simply
return `0` while `to_count` would return an error; this patch changes
`to_int` to behave like `to_count`.

This introduces a breaking change in that `to_int` now raises an error
for trailing spaces (but still accepts leading spaces) where it
previously would have silently accepted it. This is consistent with
the behavior of `to_count`, but one could also argue that both of
these should only accept properly trimmed input; I did not go that route
since that would introduce breaking changes for both these functions
instead of for just one of them.
This commit is contained in:
Benjamin Bannier 2025-02-18 10:10:33 +01:00
parent 742f17fb15
commit 55533e12d4
2 changed files with 8 additions and 9 deletions

View file

@ -1 +1,3 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
error in <...>/to_int.zeek, line 10: bad conversion to integer (to_int(not an int) and not an int)
error in <...>/to_int.zeek, line 13: bad conversion to integer (to_int(206 ) and 206 )