mirror of
https://github.com/zeek/zeek.git
synced 2025-10-17 14:08:20 +00:00
Check for integral slice indexes, add extra test for [:]
This commit is contained in:
parent
f1383d98c2
commit
964e2c91a3
3 changed files with 4 additions and 0 deletions
|
@ -484,6 +484,8 @@ expr:
|
||||||
set_location(@1, @6);
|
set_location(@1, @6);
|
||||||
Expr* low = $3 ? $3 : new ConstExpr(val_mgr->GetCount(0));
|
Expr* low = $3 ? $3 : new ConstExpr(val_mgr->GetCount(0));
|
||||||
Expr* high = $5 ? $5 : new SizeExpr($1);
|
Expr* high = $5 ? $5 : new SizeExpr($1);
|
||||||
|
if ( ! IsIntegral(low->Type()->Tag()) || ! IsIntegral(high->Type()->Tag()) )
|
||||||
|
reporter->FatalError("slice notation must have integral values as indexes");
|
||||||
ListExpr* le = new ListExpr(low);
|
ListExpr* le = new ListExpr(low);
|
||||||
le->Append(high);
|
le->Append(high);
|
||||||
$$ = new IndexExpr($1, le, true);
|
$$ = new IndexExpr($1, le, true);
|
||||||
|
|
|
@ -62,3 +62,4 @@ slicing (PASS)
|
||||||
slicing (PASS)
|
slicing (PASS)
|
||||||
slicing (PASS)
|
slicing (PASS)
|
||||||
slicing (PASS)
|
slicing (PASS)
|
||||||
|
slicing (PASS)
|
||||||
|
|
|
@ -174,4 +174,5 @@ event zeek_init()
|
||||||
test_case( "slicing", all_set(v17[-3:-1] == vector( 3, 4 )) );
|
test_case( "slicing", all_set(v17[-3:-1] == vector( 3, 4 )) );
|
||||||
test_case( "slicing", all_set(v17[:2] == vector( 1, 2 )) );
|
test_case( "slicing", all_set(v17[:2] == vector( 1, 2 )) );
|
||||||
test_case( "slicing", all_set(v17[2:] == vector( 3, 4, 5 )) );
|
test_case( "slicing", all_set(v17[2:] == vector( 3, 4, 5 )) );
|
||||||
|
test_case( "slicing", all_set(v17[:] == v17) );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue