@@ -1270,47 +1270,51 @@ class Interpreter {
1270
1270
return nullptr ;
1271
1271
}
1272
1272
1273
- void jsonToHeap (const std::unique_ptr<JsonnetJsonValue> &v, Value &attach)
1273
+ void jsonToHeap (const std::unique_ptr<JsonnetJsonValue> &v, bool &filled, Value &attach)
1274
1274
{
1275
1275
// In order to not anger the garbage collector, assign to attach immediately after
1276
1276
// making the heap object.
1277
1277
switch (v->kind ) {
1278
1278
case JsonnetJsonValue::STRING:
1279
1279
attach = makeString (decode_utf8 (v->string ));
1280
+ filled = true ;
1280
1281
break ;
1281
1282
1282
1283
case JsonnetJsonValue::BOOL:
1283
1284
attach = makeBoolean (v->number != 0.0 );
1285
+ filled = true ;
1284
1286
break ;
1285
1287
1286
1288
case JsonnetJsonValue::NUMBER:
1287
1289
attach = makeDouble (v->number );
1290
+ filled = true ;
1288
1291
break ;
1289
1292
1290
1293
case JsonnetJsonValue::NULL_KIND:
1291
1294
attach = makeNull ();
1295
+ filled = true ;
1292
1296
break ;
1293
1297
1294
1298
case JsonnetJsonValue::ARRAY: {
1295
1299
attach = makeArray (std::vector<HeapThunk*>{});
1300
+ filled = true ;
1296
1301
auto *arr = static_cast <HeapArray*>(attach.v .h );
1297
1302
for (size_t i = 0 ; i < v->elements .size () ; ++i) {
1298
1303
arr->elements .push_back (
1299
1304
makeHeap<HeapThunk>(idArrayElement, nullptr , 0 , nullptr ));
1300
- arr->elements [i]->filled = true ;
1301
- jsonToHeap (v->elements [i], arr->elements [i]->content );
1305
+ jsonToHeap (v->elements [i], arr->elements [i]->filled , arr->elements [i]->content );
1302
1306
}
1303
1307
} break ;
1304
1308
1305
1309
case JsonnetJsonValue::OBJECT: {
1306
1310
attach = makeObject<HeapComprehensionObject>(
1307
1311
BindingFrame{}, jsonObjVar, idJsonObjVar, BindingFrame{});
1312
+ filled = true ;
1308
1313
auto *obj = static_cast <HeapComprehensionObject*>(attach.v .h );
1309
1314
for (const auto &pair : v->fields ) {
1310
1315
auto *thunk = makeHeap<HeapThunk>(idJsonObjVar, nullptr , 0 , nullptr );
1311
1316
obj->compValues [alloc->makeIdentifier (decode_utf8 (pair.first ))] = thunk;
1312
- thunk->filled = true ;
1313
- jsonToHeap (pair.second , thunk->content );
1317
+ jsonToHeap (pair.second , thunk->filled , thunk->content );
1314
1318
}
1315
1319
} break ;
1316
1320
}
@@ -2092,7 +2096,8 @@ class Interpreter {
2092
2096
std::unique_ptr<JsonnetJsonValue> r (cb.cb (cb.ctx , &args3[0 ], &succ));
2093
2097
2094
2098
if (succ) {
2095
- jsonToHeap (r, scratch);
2099
+ bool unused;
2100
+ jsonToHeap (r, unused, scratch);
2096
2101
} else {
2097
2102
if (r->kind != JsonnetJsonValue::STRING) {
2098
2103
throw makeError (
0 commit comments