Skip to content

fix(typescript): module-level function fallback in get_method (local + Neo4j) - #251

Merged
rahlk merged 2 commits into
mainfrom
fix/issue-247
Jul 14, 2026
Merged

fix(typescript): module-level function fallback in get_method (local + Neo4j)#251
rahlk merged 2 commits into
mainfrom
fix/issue-247

Conversation

@rahlk

Copy link
Copy Markdown
Collaborator

Closes#247.

What

The TypeScript backends' get_method was class-scope only — module-level functions (the dominant callable kind in TS) were unreachable, and get_method_parameters inherited the miss. Fixed on both backends:

  • Local: on class-lookup miss, falls back to module-level function resolution via _functions (exact signature first, then short-name scoped by prefix).
  • Neo4j: same semantics via a DECLARES-based fallback query mirroring get_all_functions' pattern, including _module IN $mods app scoping.
  • Docs: ABC docstring documents the scope-accepts-module semantics.
  • _resolve_signature's composed-guess fallback is deliberately untouched (miss discrimination is #249).

Tests

New tests/analysis/typescript/test_typescript_get_method_functions.py (16 tests): self-contained pydantic fixture + stubbed-_run Neo4j tests that exercise the real reconstruction path (_callable_fullR.callable_ with real parameters_json decoding), plus backend-parity and genuine-miss pins. TDD RED→GREEN. Matching integration tests added to the two golden-fixture files.

Gate on head ec284c1: tests/analysis/typescript26 passed, 19 skipped, 23 errors; all 23 errors are the pre-existing missing golden fixture (tests/resources/typescript/analysis_json/slim/analysis.json), byte-identical on unmodified main; skips are Neo4j gating.

Notes for reviewers

  • The two test_get_method_parameters_module_level_function integration tests assert the exact (empty) parameter list of the fixture's zero-arg main — smoke-grade only, since a miss also yields []; the dedicated suite's parameterized-function assertions carry the discriminating load. Worth revisiting when the golden fixture is restored in CI.
  • Pre-existing (not touched here): the Neo4j get_method HAS_METHOD query lacks the _module IN $mods scoping its new fallback and get_all_functions have — tracked in the #249 discussion.
  • Accepted lookup key forms after this fix: class signature + member name, OR full signature under any scope (global exact-signature fallback). Languages differ in accepted key forms — relevant for the future cross-language contract suite.

rahlk added 2 commits July 14, 2026 10:40
get_method only ever looked at _methods_by_class (local backend) / matched
[:HAS_METHOD] (Neo4j backend), so module- and namespace-level functions --
the dominant callable kind in most TS code -- were unreachable through it,
and get_method_parameters inherited the false-empty miss.
Both backends now fall back to function resolution when the class lookup
misses: an exact signature match first, then a short-name match scoped
under the given class/module/namespace. The local backend resolves against
_functions; the Neo4j backend runs a DECLARES-based fallback query mirroring
get_all_functions. _resolve_signature's composed-guess fallback is untouched.
@rahlk
rahlk merged commit 8d27aff into mainJul 14, 2026
@rahlk
rahlk deleted the fix/issue-247 branch July 14, 2026 15:59
@rahlkrahlk added the fix Bug fixes label Jul 14, 2026
@rahlkrahlk mentioned this pull request Jul 14, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fixBug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(typescript): get_method class-only — module-level functions unreachable (local + Neo4j)

1 participant

@rahlk