Skip to content

Commit 0263cae

Browse files
committed
No empty array
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent c73bf9c commit 0263cae

4 files changed

Lines changed: 5 additions & 34 deletions

File tree

src/evaluator/include/sourcemeta/blaze/evaluator_dispatch.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2208,7 +2208,8 @@ INSTRUCTION_HANDLER(LoopItemsPropertiesExactlyTypeStrictHash3) {
22082208
}
22092209

22102210
INSTRUCTION_HANDLER(LoopItemsIntegerBounded) {
2211-
EVALUATE_BEGIN_NON_STRING(LoopItemsIntegerBounded, target.is_array());
2211+
EVALUATE_BEGIN_NON_STRING(LoopItemsIntegerBounded,
2212+
target.is_array() && !target.empty());
22122213
const auto value{assume_value_copy<ValueIntegerBounds>(instruction.value)};
22132214
result = true;
22142215
for (const auto &element : target.as_array()) {

test/evaluator/evaluator_2020_12.json

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,17 +1890,7 @@
18901890
},
18911891
"instance": [],
18921892
"valid": true,
1893-
"fast": {
1894-
"pre": [
1895-
[ "LoopItemsIntegerBounded", "/items", "#/items", "" ]
1896-
],
1897-
"post": [
1898-
[ true, "LoopItemsIntegerBounded", "/items", "#/items", "" ]
1899-
],
1900-
"descriptions": [
1901-
"Every item in the array was expected to be a number within the given range"
1902-
]
1903-
},
1893+
"fast": {},
19041894
"exhaustive": {}
19051895
},
19061896
{

test/evaluator/evaluator_draft4.json

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9877,17 +9877,7 @@
98779877
},
98789878
"instance": [],
98799879
"valid": true,
9880-
"fast": {
9881-
"pre": [
9882-
[ "LoopItemsIntegerBounded", "/items", "#/items", "" ]
9883-
],
9884-
"post": [
9885-
[ true, "LoopItemsIntegerBounded", "/items", "#/items", "" ]
9886-
],
9887-
"descriptions": [
9888-
"Every item in the array was expected to be a number within the given range"
9889-
]
9890-
},
9880+
"fast": {},
98919881
"exhaustive": {
98929882
"pre": [
98939883
[ "LoopItems", "/items", "#/items", "" ]

test/evaluator/evaluator_draft6.json

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3316,17 +3316,7 @@
33163316
},
33173317
"instance": [],
33183318
"valid": true,
3319-
"fast": {
3320-
"pre": [
3321-
[ "LoopItemsIntegerBounded", "/items", "#/items", "" ]
3322-
],
3323-
"post": [
3324-
[ true, "LoopItemsIntegerBounded", "/items", "#/items", "" ]
3325-
],
3326-
"descriptions": [
3327-
"Every item in the array was expected to be a number within the given range"
3328-
]
3329-
},
3319+
"fast": {},
33303320
"exhaustive": {
33313321
"pre": [
33323322
[ "LoopItems", "/items", "#/items", "" ]

0 commit comments

Comments
 (0)