mirror of
https://github.com/zeek/zeek.git
synced 2025-10-16 21:48:21 +00:00
GH-251 (revert): remove coercion-to-signed-integer for |x| expressions
For `|x|`, where `x` is an expression with an integral result, an implicit coercion of that result into signed `int` type no longer takes place. This was actually the behavior before Zeek 3.0 as well, but the attempt to prevent mistakes that easily result from integer literals in Zeek being unsigned like `|5 - 9|` causing an overflow/wraparound and yielding a very large number is not generally consistent since overflows are still generally able to happen in other ways and also in other contexts besides just absolute-values. So the preference was to revert to a behavior that favors consistency. For reference, see https://github.com/zeek/zeek/pull/251#issuecomment-713956976
This commit is contained in:
parent
22ef67888c
commit
73c1af838c
5 changed files with 22 additions and 8 deletions
|
@ -767,10 +767,6 @@ expr:
|
|||
{
|
||||
zeek::detail::set_location(@1, @3);
|
||||
zeek::detail::ExprPtr e{zeek::AdoptRef{}, $2};
|
||||
|
||||
if ( zeek::IsIntegral(e->GetType()->Tag()) )
|
||||
e = zeek::make_intrusive<zeek::detail::ArithCoerceExpr>(std::move(e), zeek::TYPE_INT);
|
||||
|
||||
$$ = new zeek::detail::SizeExpr(std::move(e));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue