One invalid token at the bottom of DEEP_NEST_LEVELS parentheses. Every * enclosing parenthesized_expression then carries ts_node_has_error without * being an ERROR node, which is the chain cbm_collect_error_regions (cbm.c) * descends: it steps into a child that contains an error and stops at the * top-most ERROR or MISSING node. Nested ERROR nodes would not do — the walk * never enters an ERR
| 11535 | * region, on the line of the nest only, with the neighbouring definition |
| 11536 | * intact and the file still usable. */ |
| 11537 | static int deep_error_regions_probe(void) { |
| 11538 | uint32_t core_at = 0; |
| 11539 | char *src = build_nested_source("def ok():\n return 1\nx = ", "1 2", "\ny = ok()\n", |
| 11540 | DEEP_NEST_LEVELS, &core_at); |
| 11541 | if (!src) { |
| 11542 | return 4; |
| 11543 | } |
| 11544 | CBMFileResult *r = extract(src, CBM_LANG_PYTHON, "t", "deep_error.py"); |
| 11545 | int rc = 0; |
| 11546 | if (!r) { |
| 11547 | printf(" deep error regions: extraction failed\n"); |
| 11548 | rc = 1; |
| 11549 | } else { |
| 11550 | if (!r->parse_incomplete || r->error_region_count != 1 || !r->error_ranges || |
| 11551 | strcmp(r->error_ranges, "3-3") != 0) { |
| 11552 | printf(" deep error regions: incomplete=%d count=%d ranges=%s, expected one " |
| 11553 | "region 3-3\n", |
| 11554 | r->parse_incomplete ? 1 : 0, r->error_region_count, |
| 11555 | r->error_ranges ? r->error_ranges : "(none)"); |
| 11556 | rc = 1; |
| 11557 | } |
| 11558 | if (r->parse_unusable) { |
| 11559 | printf(" deep error regions: one line of five must not make the file unusable\n"); |
| 11560 | rc = 1; |
| 11561 | } |
| 11562 | if (!has_def(r, "Function", "ok")) { |
| 11563 | printf(" deep error regions: the definition next to the nest was lost\n"); |
| 11564 | rc = 1; |
| 11565 | } |
| 11566 | cbm_free_result(r); |
| 11567 | } |
| 11568 | free(src); |
| 11569 | return rc; |
| 11570 | } |
| 11571 | |
| 11572 | TEST(extract_deep_error_regions_complete) { |
| 11573 | char why[160]; |
nothing calls this directly
no test coverage detected