Skip to content

Julia WASM extractor: abstract_definition / macro_definition / signature-call-skip bugs #1126

@carlos-alm

Description

@carlos-alm

Found while fixing #1111. Out of scope for that PR, filing separately.

The WASM Julia extractor at src/extractors/julia.ts has three additional bugs surfaced by comparison with the native extractor (crates/codegraph-core/src/extractors/julia.rs), none of which are exercised by existing WASM fixtures:

1. handleAbstractDef never extracts abstract types

The tree-sitter-julia grammar nests the identifier inside type_head:

abstract_definition
  type_head
    identifier "AbstractShape"

Current code:

const nameNode = node.childForFieldName('name') || findChild(node, 'identifier');

findChild(node, 'identifier') only inspects direct children of abstract_definition, so it returns null for every input. As a result, no abstract type definitions are ever recorded on the WASM side — including the existing native test extracts_abstract_type (abstract type AbstractShape end) and extracts_parameterized_abstract_type_base_name (abstract type AbstractVector{T} <: AbstractArray{T,1} end).

Native fix in crates/codegraph-core/src/extractors/julia.rs handle_abstract_def falls back to find_child(node, "type_head") → find_base_name(...).

2. handleMacroDef finds wrong identifier

For macro mymac(x) x end, findChild(node, 'identifier') finds the body's x (the macro returns x), recording the macro as @x instead of @mymac. The native code uses the signature_call helper (now also present in WASM as signatureCall after #1111) to unwrap macro_definition → signature → call_expression → identifier.

3. handleCall doesn't skip the function/macro signature

Current guard:

if (node.parent?.type === 'function_definition') return;

The signature's call_expression actually has parent.type === 'signature', not function_definition. As a result, function greet(name) ... end records both a definition greet and a call named greet. The native code (julia.rs, handle_call) skips when parent.kind() == \"signature\" and the grandparent is function_definition or macro_definition. The native test does_not_record_function_signature_as_call covers this.

Acceptance criteria

Metadata

Metadata

Assignees

No one assigned

    Labels

    follow-upDeferred work from PR reviews that needs tracking

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions