Skip to content

Commit 23fd0e8

Browse files
authored
Merge pull request #982 from Dhruvy0804/fix/issue-842-clobber-class
fix(pipeline): guard env-access CONFIGURES and throws sources against…
2 parents 4071877 + 17f856c commit 23fd0e8

5 files changed

Lines changed: 419 additions & 4 deletions

File tree

Makefile.cbm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ TEST_REPRO_SRCS = \
447447
tests/repro/repro_issue363.c \
448448
tests/repro/repro_issue581.c \
449449
tests/repro/repro_issue787.c \
450+
tests/repro/repro_issue842.c \
450451
tests/repro/repro_invariant_calls.c \
451452
tests/repro/repro_invariant_graph.c \
452453
tests/repro/repro_invariant_breadth.c \

src/pipeline/pass_definitions.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,12 @@ static int create_env_configures_for_file(cbm_pipeline_ctx_t *ctx, const CBMFile
425425
const cbm_gbuf_node_t *src = NULL;
426426
if (ea->enclosing_func_qn && ea->enclosing_func_qn[0]) {
427427
src = cbm_gbuf_find_by_qn(ctx->gbuf, ea->enclosing_func_qn);
428+
/* A class-level env access in a directory-module language carries
429+
* the DIRECTORY module QN, which hits the shared Folder/Project
430+
* node — attribute to this file's File node instead (#787, #842). */
431+
if (cbm_pipeline_node_is_dir_container(src)) {
432+
src = NULL;
433+
}
428434
}
429435
if (!src) {
430436
if (!file_qn) {

src/pipeline/pass_parallel.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2406,14 +2406,18 @@ static void resolve_file_usages(resolve_ctx_t *rc, resolve_worker_state_t *ws,
24062406

24072407
/* Resolve throws/raises for one file. */
24082408
static void resolve_file_throws(resolve_ctx_t *rc, resolve_worker_state_t *ws,
2409-
CBMFileResult *result, const char *module_qn, const char **imp_keys,
2410-
const char **imp_vals, int imp_count) {
2409+
CBMFileResult *result, const char *rel, const char *module_qn,
2410+
const char **imp_keys, const char **imp_vals, int imp_count) {
24112411
for (int t = 0; t < result->throws.count; t++) {
24122412
CBMThrow *thr = &result->throws.items[t];
24132413
if (!thr->exception_name || !thr->enclosing_func_qn) {
24142414
continue;
24152415
}
2416-
const cbm_gbuf_node_t *src = cbm_gbuf_find_by_qn(rc->main_gbuf, thr->enclosing_func_qn);
2416+
/* find_source_node falls back to the per-file File node when the
2417+
* lookup lands on a shared Folder/Project node (#787, #842) — same
2418+
* guard resolve_file_calls/usages/rw already use. */
2419+
const cbm_gbuf_node_t *src =
2420+
find_source_node(rc->main_gbuf, rc->project_name, rel, thr->enclosing_func_qn);
24172421
if (!src) {
24182422
continue;
24192423
}
@@ -2822,7 +2826,7 @@ static void resolve_worker(int worker_id, void *ctx_ptr) {
28222826

28232827
/* ── THROWS / RAISES ───────────────────────────────────── */
28242828
_ph_t0 = extract_now_ns();
2825-
resolve_file_throws(rc, ws, result, module_qn, imp_keys, imp_vals, imp_count);
2829+
resolve_file_throws(rc, ws, result, rel, module_qn, imp_keys, imp_vals, imp_count);
28262830
atomic_fetch_add_explicit(&rc->time_ns_throws, extract_now_ns() - _ph_t0,
28272831
memory_order_relaxed);
28282832

0 commit comments

Comments
 (0)