test(julia): cover macro signature guard branch#1150
Conversation
…t fixes to WASM The native Julia extractor was fixed in #1098 for three issues that were already latent in the WASM extractor but not surfaced by the existing fixtures. Per the dual-engine policy, port the fixes so both engines produce identical results. 1. Parameterized struct names (`struct Vec{T} <: AbstractArray{T,1}`) no longer silently emit the raw type-head text as the definition name — `findBaseName` recurses through `binary_expression`, `parametrized_type_expression`, and related wrappers to locate the base identifier. 2. Qualified function defs / short-form methods inside a module no longer get double-prefixed: `function Base.show ... end` inside `module Foo` now records `Base.show` (not `Foo.Base.show`); same for short-form `Foo.bar(x, y) = x + y` inside `module Outer`. 3. `selected_import` with a qualified module (`import LinearAlgebra.BLAS: gemm`) now correctly records `LinearAlgebra.BLAS` as the import source and `gemm` as the imported name. Also fixes a related latent bug: `findChild(node, 'call_expression')` on a `function_definition` was matching the body's first call (e.g. `println(...)`) instead of the signature, because the signature is wrapped in a `signature` node. Added a `signatureCall` helper mirroring the native code. Closes #1111
…ype test (#1128) - Remove type_parameter_list / type_argument_list from TYPE_HEAD_WRAPPERS in both WASM and native engines. Julia grammar uses curly_expression for {T} constructs, so these were dead code. Removing them prevents findBaseName from ever recursing into a type-parameter list and returning a type variable (e.g. T) instead of the struct name. - Add WASM test for non-parameterized struct inheritance (struct Point <: AbstractPoint). The native engine already covers this case; the WASM side now has parity.
…lback (#1128) - Strengthen the `import Base: show` test to assert the corrected source/names shape (was only checking that imports were emitted at all, so a regression to the broken pre-fix shape would have slipped through). - Document the grammar assumption behind `signatureCall` / `signature_call` in both engines: the call_expression fallback exists only for defensive grammar-drift protection, not as a routine path — if it ever fires on a real definition, the function name will silently match the first body call_expression instead.
…1130) * fix(julia): port abstract-def / macro-def / signature-call WASM bugs The WASM Julia extractor diverged from the native Rust extractor in three ways that no existing WASM fixture exercised: - handleAbstractDef: `findChild(node, 'identifier')` only looks at direct children of `abstract_definition`, but tree-sitter-julia nests the identifier inside `type_head`. Result: no abstract type was ever recorded. Fall back to `findBaseName(typeHead)` like the native code. - handleMacroDef: `findChild(node, 'identifier')` resolves to the body's first identifier rather than the macro name (e.g. `macro mymac(x) x end` recorded `@x` instead of `@mymac`). Unwrap via `signatureCall` to reach the call_expression name. - handleCall: the guard `parent.type === 'function_definition'` never matched — the signature's call_expression is parented by `signature`, whose own parent is the function/macro definition. Result: every long-form `function greet(...) ... end` recorded `greet` as both a definition and a call. Match the native walk: skip when parent is `signature` and grandparent is `function_definition` or `macro_definition`. Adds WASM tests mirroring the native cases: extracts_abstract_type, extracts_parameterized_abstract_type_base_name, extracts_macro_def, and does_not_record_function_signature_as_call. Closes #1126 * fix(julia): align abstract-def name resolution with struct-def (#1130)
Mirrors the function-signature guard test for the `macro_definition` grandparent branch in `handleCall`. Without this case, a future tree-sitter-julia grammar change that breaks the macro branch would slip through the WASM test suite. A test was prepared during PR #1130 review but landed on the head branch after the squash-merge, so it is missing from history. Closes #1137
|
Claude finished @carlos-alm's task —— View job PR Review: test(julia): cover macro signature guard branchTodo List:
Root Cause AnalysisProblem Being Solved: This PR adds test coverage for the macro signature guard branch in the Julia extractor's Why This Approach: The test mirrors the existing "does not record function signature as call" test (lines 143-153) but covers the Risk Assessment: ✅ Low risk - This is a pure test addition that increases coverage of existing defensive logic. Backlog Compliance
Code Quality AssessmentTest Implementation (lines 155-165): ✅ Excellent
Coverage Validation: ✅ Strong
Code Consistency: ✅ Perfect
Guard Logic AnalysisThe tested code (lines 382-385) correctly prevents this scenario: macro mymac(x)
println(x)
endFrom incorrectly recording
This is critical for accurate dependency analysis - without this guard, macros would appear to call themselves, confusing the dependency graph. Final AssessmentMinor Note: The only reason this isn't 5/5 is that it's a straightforward test addition rather than solving a complex problem, but it's executed flawlessly. |
Greptile SummaryThis PR adds a single regression test to the Julia parser test suite that guards against macro signature names being incorrectly recorded as function calls. The test directly mirrors the existing
Confidence Score: 5/5Test-only addition with no production code changes; safe to merge. The change is a single, focused test that matches the shape of existing tests in the suite, exercises a real guard in the extractor, and was confirmed to catch a real regression. No production code is touched. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["parseJulia(macro mymac(x)\n println(x)\nend)"]
B["tree-sitter-julia AST"]
C["macro_definition node\n └─ signature\n └─ call_expression (mymac)"]
D["handleCall(call_expression)"]
E{"parent.type === 'signature'\nAND\ngrand.type === 'macro_definition'?"}
F["return — skip recording\n✅ mymac NOT in calls"]
G["body call_expression (println)"]
H["handleCall(println)"]
I["record call\n✅ println IN calls"]
A --> B --> C
C --> D --> E
E -- yes --> F
B --> G --> H --> I
Reviews (7): Last reviewed commit: "Merge branch 'main' into test/1137-julia..." | Re-trigger Greptile |
Summary
does not record macro signature as calltest totests/parsers/julia.test.ts, mirroring the existing function-signature guard test for themacro_definitiongrandparent branch.handleCallinsrc/extractors/julia.ts, so it would catch a future tree-sitter-julia grammar regression on macros.The test was prepared during PR #1130 review (commit 6ae097b on
fix/1126-julia-wasm-extractor-bugs) but landed after the squash-merge, so it never reached this branch's history.Closes #1137
Test plan
npx vitest run tests/parsers/julia.test.ts— all 16 tests pass.macro_definitionarm of thehandleCallguard and confirmed the new test fails withexpected [ 'mymac', 'println' ] to not include 'mymac', then restored.