GH-219: revert previous change to |x| operator for interval/time

The result of the |x| operator for interval and time types historically
returned a value of type double.  This was changed as part of
3256ac7c49 to return interval/time, but
this now reverts to returning a double again to avoid introducing a
change that may break user code.

Fixes GH-219
This commit is contained in:
Jon Siwek 2019-03-06 15:30:58 -08:00
parent 8b9d525097
commit 628a46d8fd
6 changed files with 11 additions and 7 deletions

View file

@ -1,4 +1,8 @@
2.6-132 | 2019-03-06 15:30:58 -0800
* GH-219: revert a breaking change to |x| operator for interval/time (Jon Siwek, Corelight)
2.6-130 | 2019-02-22 14:56:41 -0600 2.6-130 | 2019-02-22 14:56:41 -0600
* Make input framework parse whitespace around various data types. (Johanna Amann, Corelight) * Make input framework parse whitespace around various data types. (Johanna Amann, Corelight)

View file

@ -1 +1 @@
2.6-130 2.6-132

View file

@ -1382,7 +1382,7 @@ SizeExpr::SizeExpr(Expr* arg_op) : UnaryExpr(EXPR_SIZE, arg_op)
return; return;
if ( op->Type()->InternalType() == TYPE_INTERNAL_DOUBLE ) if ( op->Type()->InternalType() == TYPE_INTERNAL_DOUBLE )
SetType(op->Type()->Ref()); SetType(base_type(TYPE_DOUBLE));
else else
SetType(base_type(TYPE_COUNT)); SetType(base_type(TYPE_COUNT));
} }

View file

@ -425,7 +425,7 @@ Val* Val::SizeVal() const
return val_mgr->GetCount(val.uint_val); return val_mgr->GetCount(val.uint_val);
case TYPE_INTERNAL_DOUBLE: case TYPE_INTERNAL_DOUBLE:
return new Val(fabs(val.double_val), type->Tag()); return new Val(fabs(val.double_val), TYPE_DOUBLE);
case TYPE_INTERNAL_OTHER: case TYPE_INTERNAL_OTHER:
if ( type->Tag() == TYPE_FUNC ) if ( type->Tag() == TYPE_FUNC )

View file

@ -70,9 +70,9 @@ event bro_init()
test_case( "compare different time units", in13 >= in35 ); test_case( "compare different time units", in13 >= in35 );
test_case( "add different time units", in13 + in14 == 4min ); test_case( "add different time units", in13 + in14 == 4min );
test_case( "subtract different time units", in24 - in23 == 0sec ); test_case( "subtract different time units", in24 - in23 == 0sec );
test_case( "absolute value", |in25| == 2hr ); test_case( "absolute value", |in25| == 2.0*3600 );
test_case( "absolute value", |in36| == 2.5day ); test_case( "absolute value", |in36| == 2.5*86400 );
test_case( "absolute value", |5sec - 9sec| == 4sec ); test_case( "absolute value", |5sec - 9sec| == 4.0 );
in34 += 2hr; in34 += 2hr;
test_case( "assignment operator", in34 == 122min ); test_case( "assignment operator", in34 == 122min );
in34 -= 2hr; in34 -= 2hr;

View file

@ -27,7 +27,7 @@ event bro_init()
test_case( "inequality", t1 != t3 ); test_case( "inequality", t1 != t3 );
test_case( "equality", t1 == t4 ); test_case( "equality", t1 == t4 );
test_case( "subtract time", t2 - t1 == 3sec); test_case( "subtract time", t2 - t1 == 3sec);
test_case( "size operator", |t5| == t5 ); test_case( "size operator", |t5| == 1234567890.0 );
} }