Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

JS stack graphs fail to resolve identifiers when multiple case labels share a single branch #499

@Lexxxzy

Description

@Lexxxzy

In the JavaScript stack graphs, name resolution inside a switch statement breaks when multiple case labels precede a single consequent. The scope/flow modeling appears to keep the first branch “open” across subsequent cases, causing references in later cases to lose access to outer-scope bindings. Splitting the cases so that each label has its own block makes the problem disappear.

Failing example (multiple case labels share one branch)

function print(string) {
  console.log(string);
}

switch (type) {
  case "Int8Array":
  case "BigUint64Array": {
    console.log("Int Array");
  }

  case "ArrayBuffer": {
    print(base64); // not resolving
  }
}
Observed result from navigation/definitions:
 |            print(base64);
 |            ^^^^

has no definitions

Passing example (each case has its own block)

function print(string) {
  console.log(string);
}

switch (type) {
  case "Int8Array": {
    console.log("something");
  }

  case "ArrayBuffer": {
    print(base64); // resolves successfully
  }
}

Expected behavior

print in the case "ArrayBuffer" branch should resolve to the function declared above, regardless of how many case labels precede other branches.

Actual behavior

When multiple case labels share a single consequent earlier in the switch, subsequent branches report references as unresolved (“has no definitions”).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions