Skip to content

[Bug]: vbnet: no calls edge through field receivers or With blocks (WinForms-style forms) #4588

Open

Description

@TerraVenil

Pre-flight checks

  • I have checked the Troubleshooting section in the README

What happened?

Follow-up to #4570 / #4573, as suggested in the PR discussion. With #4573 (0fcda3a129), a VB.NET call through a parameter or a typed local gets its calls edge. A call through a field, or through a With block, still gets none. #4573 records both as expected-failure tests (field; With on a local).

In WinForms-style VB these are the usual shapes. A form holds its collaborators in fields, often initialised in the declaration or declared in the other half of a partial class (Form1.Designer.vb), and uses With blocks on them. So in a form most outgoing calls to other classes have no edge, and affected / path miss those callers.

This repro covers the shapes beyond the two in #4573's tests, one method per case:

Expected: a calls edge for each case. In each, the receiver's type is declared in the same statement or field declaration and names exactly one type in the corpus. The C# equivalent, private Store _store = new Store(); then _store.Save(), does get an edge.

Steps to reproduce

Four files in one folder:

`Repository.vb`
Public Class Repository
    Public Sub Load(id As Integer)
    End Sub
    Public Sub Save()
    End Sub
End Class

`PriceRules.cs`
namespace Shop.Rules
{
    public class PriceRules
    {
        public decimal Total(int id) { return 0m; }
    }
}

`OrderForm.Designer.vb`
Partial Class OrderForm
    Inherits System.Windows.Forms.Form

    Friend Archive As New Repository()
End Class

`OrderForm.vb`
Partial Class OrderForm
    Private _repository As New Repository()
    Private _rules As New Shop.Rules.PriceRules()
    Private _late As Repository

    Public Sub New()
        _late = New Repository()
    End Sub

    Public Sub F1_FieldNew()
        _repository.Load(1)
    End Sub
    Public Sub F2_FieldAssignedLater()
        _late.Save()
    End Sub
    Public Sub F3_MeField()
        Me._repository.Save()
    End Sub
    Public Sub F4_FieldCSharp()
        _rules.Total(1)
    End Sub
    Public Sub F5_FieldInOtherPartialFile()
        Archive.Save()
    End Sub

    Public Sub W1_WithField()
        With _repository
            .Load(2)
        End With
    End Sub
    Public Sub W2_WithLocal()
        Dim r As New Repository()
        With r
            .Save()
        End With
    End Sub
    Public Sub W3_WithNew()
        With New Repository()
            .Load(3)
        End With
    End Sub
    Public Sub W4_WithFieldCSharp()
        With _rules
            .Total(2)
        End With
    End Sub

    Public Sub P1_Parameter(x As Repository)
        x.Save()
    End Sub
End Class

GRAPHIFY_BACKEND=none graphify extract fields-repro --code-only

`graphify explain` on each case method shows whether it has an outgoing `calls` edge:

graphify explain "F1_FieldNew()" --graph fields-repro/graphify-out/graph.json    # only the <-- OrderForm [method] edge
graphify explain "P1_Parameter()" --graph fields-repro/graphify-out/graph.json   # --> Save() [calls] [INFERRED]

Error output or graph output

MISSING F1_ -> Load
MISSING F2_ -> Save
MISSING F3_ -> Save
MISSING F4_ -> Total
MISSING F5_ -> Save
MISSING W1_ -> Load
MISSING W2_ -> Save
MISSING W3_ -> Load
MISSING W4_ -> Total
FOUND   P1_ -> Save

Graphify version

0.9.92

Operating System

Windows

Python Version

3.13

Installation Method

uv tool install (recommended)

Additional Environment Details

GRAPHIFY_BACKEND=none, --code-only; no provider API keys set. Reproduced in a fresh folder that contains only the four files above. Output above is from the #4573 branch (0fcda3a129); on 0.9.92 from PyPI all ten cases are MISSING, including P1.

Additional context

Activity

  1. added
    bug
    on Oct 20, 2026
  2. github-actions commented on Oct 20, 2026

    @github-actions

    Thanks for opening this issue, @TerraVenil. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

  3. Deepjyoti-Sarmah commented on Oct 20, 2026

    @Deepjyoti-Sarmah
    Contributor

    Thanks for the repro. It reproduces on the #4573 branch exactly as reported, and I'll take this one.

    Each case is lost in one of two places:

    • F1, F2, F4 and F5 (_field.Method()): the extractor records the call, but the receiver goes out as a plain name with no type, because only locals and parameters have a name -> declared type table. The resolver tries the name as a type or Module, finds it's a field (hidden_by_member) and gives up. The field nodes don't carry their declared type either, so there would be nothing to look up.
    • F3 and W1-W4: the extractor drops the call before the resolver sees it. Me._repository counts as an expression of unknown type. A .Load() call has no receiver in its own text, and the extractor doesn't track With blocks. That drop is deliberate: on v8, a .Save() inside With bound to the caller's own Save when the caller had one.

    Plan:

    1. Store each field's declared type (As T, As New T(), = New T()) on the field node. The resolver looks fields up per class, across partial files and base classes, after locals and parameters. That covers F1-F5, including Archive in the Designer file.
    2. Keep a stack of With targets while walking a method, so .Load() becomes a call on the innermost target (a field, a typed local, or New T()). A target of unknown type, like With GetThing(), still gets no edge.
    3. The new edges are INFERRED, like typed locals. F4 and W4 call into C#, so they rely on the _vbnet_resolved marker from 0fcda3a.

    Before writing the fix I'll check these against the compiler:

    • a field declared without As: I expect Private x = New Repository() to be Object, since Option Infer doesn't cover fields, which means no edge
    • a local named like a field
    • an inherited field
    • nested With blocks
    • a field typed outside the corpus, like WithEvents Button1 As Button: no edge and no stub

    The fix will be a separate PR on top of #4573.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions