Skip to content
TheChatArchiveThe Chat Archive
gpt-5.6-sol· openaiHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION unused-class-members FP: methods called only from Svelte <template>…

  1. User

    ISSUE DESCRIPTION

    unused-class-members FP: methods called only from Svelte member expressions False positive on 2.84.0. Class methods called only from a Svelte <template> via a member expression (for example resultState.pin(...) in markup) are reported as unused-class-member. Fallow tracks template-visible identifiers but not member-expression method calls on a bound instance inside Svelte markup.

    Repro (2.84.0): asciimoo/hister. ResultState.onOpen, .pin, .updateLabel, and .addSkipRule are each invoked from .svelte templates (resultState.pin(...) in ResultActionsMenu.svelte) yet reported unused. The repo currently sets rules.unused-class-members: "off" to work around it.

    Expected: credit a method called as <local>.<method>(...) inside a Svelte <template> when <local> resolves to an instance of the class, parallel to the existing Vue/Angular template member-access tracking.

    Interface

    No new interfaces are introduced.

    ADDITIONAL ADVICE

    Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use git checkout <file> to restore the file to its original state. You can also reset all changes in the repository using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to get the changes that need to be submitted.

    CHECKLIST

    Before submitting your solution, please go over the following checklist and make sure you've done everything:

    • If an error was reported in the issue description, I have successfully reproduced it.
    • If an error was reported in the issue description, I have confirmed that my fix resolves the error.
    • I have thought about edge cases and made sure my fix handles them as well.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.

    Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!

    (Current directory: /fallow, current file: none) bash-$

  2. Assistant

    I’ll first map the repository and locate the unused-class-member rule plus the existing Vue/Angular/Svelte template tracking. Then I’ll reproduce the reported pattern with the project’s test harness, make the smallest general fix, and run focused and broader tests.

  3. Assistant

    This is a Rust workspace. The likely central implementation is crates/extract/src/template_usage.rs; I’ll inspect it, the class-member analyzer, and fixture/snapshot conventions to understand how template references flow into class usage.

  4. Assistant

    TemplateUsage already supports member accesses and bound-target remapping, suggesting the missing piece is likely Svelte’s bound-target construction rather than expression parsing. Since rg is unavailable, I’ll use recursive grep and inspect all call sites and tests.

  5. Assistant

    There are already Svelte template tests for namespace accesses and later tests around bound accesses. I’ll inspect the Svelte scanner API, how sfc.rs supplies bindings, and the extractor’s instance-binding resolution (new Class → class identity), because the issue specifically requires a local instance rather than an import namespace.

  6. Assistant

    The extractor resolves bound accesses only while merging each script. Template accesses are appended afterward, so they miss that resolution pass unless the Svelte scanner itself receives the script’s binding_target_names. I’ll verify ordering and whether those targets survive merge_into, then inspect the existing Svelte bound-target tests to see what currently works.

  7. Assistant

    The current checkout already contains partial bound-target plumbing, likely an incomplete prior implementation. I need determine why the reported imported ResultState instance still fails. I’ll inspect merge_script_into_module closely—especially when targets are captured relative to factory/new resolution—and run its focused tests before changing anything.

  8. Assistant

    Targets are captured before merge_into performs deferred resolution. Direct const resultState = new ResultState() should nevertheless be immediate; I’ll verify visitor behavior and use a temporary ignored-by-git Svelte fixture or an existing unit API to reproduce exact module output and then core diagnostics. First I’ll read the current tests and test commands.

  9. Assistant

    An exact integration-style extraction test already exists, which is unusual for the described bug. I’ll check repository status/history metadata to see whether the working tree has pre-existing changes, then inspect that test and run it. This will tell us whether the remaining failure is downstream in cross-file class-member analysis rather than Svelte scanning.

  10. Assistant

    Extraction passes, but that test only asserts Counter.bump appears in the Svelte module. The core analyzer may not resolve that class name through a named import when the access originates in the same consumer module. I’ll create a minimal temporary project under /tmp with an exported class and Svelte instance, configure only unused-class-members, and run the actual CLI to reproduce the diagnostic end-to-end.

  11. Assistant

    I need invoke the named binary and confirm config syntax from existing fixtures/default config. Then I’ll run the temporary repro and compare plain markup expression and event-handler forms, since the issue’s example may be onclick={() => resultState.pin(...)}.

  12. Assistant

    No fixture explicitly enables the rule, so I’ll use default rules and filter JSON output. The temporary project will include main.ts as an entry, a .svelte component importing/instantiating ResultState, and one genuinely unused method as a control.

  13. Assistant

    The direct-construction repro is already fixed on HEAD: only the control method is reported. The real project’s ResultActionsMenu.svelte likely receives resultState as a typed component prop rather than constructing it locally (common Svelte 5 pattern: destructure $props() using a Props interface). I’ll inspect how destructured/type-aliased bindings are resolved and reproduce several realistic prop declarations; this is the likely uncovered gap behind the issue wording “bound instance.”

  14. Assistant

    The history confirms commit cadeb111 was intended to address precisely “Svelte script-instance member access.” Since direct new works, I’ll inspect that commit’s scope and test the realistic Svelte prop forms. If those fail, I’ll extend existing binding resolution generally rather than duplicating scanner logic.

  15. Assistant

    The visitor only calls record_typed_binding when a variable declaration’s binding pattern is a single identifier. Therefore both inline-typed and interface-typed $props() destructuring currently fail to bind resultState, despite being standard Svelte 5. I’ll confirm end-to-end with two temporary variants and also test an imported singleton to avoid fixing the wrong shape.

  16. Assistant

    The failure is reproduced: inline typed Svelte props report all three methods, while direct construction works. The singleton is conservatively credited wholesale, so it is not the target.

    I’ll implement general destructured typed-binding resolution in the AST visitor: correlate object binding paths (including aliases/defaults/nesting) with paths extracted from an inline structural type, then register each local identifier against its class type. This benefits ordinary TypeScript too and lets existing Svelte template remapping work unchanged. Named Props interfaces require type-declaration lookup and can be considered separately after the inline path is sound.

  17. Assistant

    There is already a reusable object-pattern path extractor used elsewhere in the visitor. I’ll inspect it and the local type declaration representation; this should allow a compact implementation for inline structural annotations and perhaps named local interfaces without introducing new public interfaces.

  18. Assistant

    The reusable extractor maps local_name → property.path, while extract_nested_type_bindings maps property.path → class type, so inline support is straightforward.

    However, Svelte code usually declares interface Props separately. To handle that robustly without changing serialized interfaces, I’ll add an extractor-internal map of local structural type shapes populated while visiting interfaces/type aliases, then resolve a variable annotation that references one of those types. Because declarations can appear after variables, resolution should occur in a finalize pass from recorded candidates, similar to existing factory-call candidates. I’ll inspect the extractor struct and interface/type-alias visitors before choosing the minimal fields.

  19. Assistant

    I’ll implement an internal, order-independent design:

    1. Generalize the existing nested-type helper to accept either a type annotation or a raw TS type/interface body.
    2. Record structural property→class mappings for local interfaces and type aliases.
    3. Record destructured annotation candidates as local→property mappings.
    4. Resolve candidates before SFC template targets are read and during normal extractor finalization.

    This remains internal and introduces no public API/schema changes.

  20. Assistant

    I’ll first refactor the helper so interface bodies and aliases share the same recursive property extraction, including intersections and nested literals. Then I’ll wire the internal maps/candidates into the visitor.

  21. Assistant

    The generalized helper is in place. Next I’ll add private structural-type state and a pending candidate type to ModuleInfoExtractor, resolve it lazily when SFC asks for template targets, and also in both normal finalization paths.

  22. Assistant

    I’ll represent each pending destructure with its local-to-property paths, optional named annotation, and any inline structural mappings. This handles aliases and defaults via the existing pattern helper and avoids retaining AST lifetimes.

  23. Assistant

    Now I’ll add the visitor logic: collect declarations, queue destructured variables, and resolve candidates. I’ll preserve the existing direct-identifier path and only act when a structural property path exactly matches, avoiding speculative bindings for rest elements or unknown properties.

  24. Assistant

    Compilation exposed two mechanical issues: helpers.rs selectively imports AST types and omitted TSInterfaceBody, and methods implemented in a child module need pub(super) visibility to be called from the parent module. I’ll correct those and re-check.

  25. Assistant

    The selective import layout did not match my replacement string; I’ll explicitly add TSInterfaceBody to that import list.

  26. Assistant

    The code now compiles. I’ll rerun the end-to-end repro for both inline structural props and a separately declared Props interface (including an aliased/defaulted destructure), ensuring only trulyUnused remains. I’ll also place one interface after the variable to verify deferred resolution.

  27. Assistant

    All three realistic prop forms now pass end-to-end and retain the unused control. Before broader tests, I’ll inspect the diff for unintended changes and run clippy/focused extractor tests. I’ll pay particular attention to type intersections, nested aliases, template-local shadowing, and ensuring normal TS member tracking remains conservative.

  28. Assistant

    Focused tests and clippy pass. The diff is confined to internal extraction. One edge-case adjustment is prudent: only module-scope interfaces/type aliases should populate the shared structural map, preventing a nested shadowing declaration from changing a Svelte/module-level prop’s type mapping. I’ll add that guard, then run the entire extractor suite and the core SFC integration tests (which validate actual unused-class-member analysis).

  29. Assistant

    The full extractor suite (1,638 tests) and all core SFC integration tests pass, including existing Vue and Svelte class-member cases. I’ll now run the core unused-member suite, workspace formatting check, and a final direct-construction regression repro. Then I’ll inspect status/diff one last time for generated or accidental files.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.