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 existing framework template tracking. Then I’ll reproduce the Svelte case with the project’s own test/fixture conventions, patch the shared analysis path, and run the focused and broader relevant tests.

  3. Assistant

    rg is unavailable, so I’ll use grep/find. This is a Rust workspace; I’m narrowing the search to source and fixture files and inspecting the workspace test commands before changing anything.

  4. Assistant

    The relevant logic is split between extraction (template_usage.rs/SFC parsing) and the core bridge in unused_members.rs. I’ll inspect the data structures and the Vue/Angular bridge carefully, then identify existing unit-test helpers so the regression can be reproduced without altering test files.

  5. Assistant

    The generic snippet analyzer already supports a bound_targets map and emits remapped member accesses. The likely gap is that Svelte script bindings are not added to that map (or Svelte uses a script form the binding collector misses). I’ll now inspect construction of bound_targets, SFC kind-specific behavior, and extractor tests around Svelte/Vue member expressions.

  6. Assistant

    There is already a Svelte bound-target regression test for an event-handler arrow, indicating the reported shape may differ in declaration form (e.g. let resultState: ResultState initialized later, Svelte $state, or imported factory). I’ll inspect exactly which script bindings are exported to templates and compare that with the hister-style declaration implied by the issue.

  7. Assistant

    The checked-in code appears to contain a recent partial fix for exactly const counter = new Counter() in Svelte, yet the issue says methods remain false positives. I need verify end-to-end rather than trust extraction-only tests. I’ll inspect the core member resolution and run/build a small temporary hister-like project through the CLI, first with a direct constructor and then likely Svelte state/prop declaration variants.

  8. Assistant

    A likely hister/Svelte 5 pattern is a typed destructured $props() binding:

    let { resultState }: { resultState: ResultState } = $props();
    

    That local semantically resolves to ResultState, but the current binding collector’s advertised cases are simple typed variables and constructors. I’ll confirm by adding no repository tests: create a temporary in-repo example/debug harness via an existing extraction test invocation or CLI project, observe the false positive, then remove it. First I’ll inspect variable-declaration binding extraction to design a general typed-destructuring fix.

  9. Assistant

    The gap is confirmed in code: visit_variable_declaration calls record_typed_binding only when the declarator itself is a BindingIdentifier; object-pattern declarations are ignored, even though helpers already understand nested object type annotations for dotted bindings. I’ll inspect those helpers and OXC AST object-pattern fields to implement recursive pairing of destructured local bindings with their corresponding annotation properties, including aliases/defaults/nesting rather than hardcoding $props.

  10. Assistant

    For inline annotations, existing utilities can pair resultState with the type path resultState -> ResultState. But idiomatic Svelte commonly uses let { resultState }: Props = $props() where Props is a local interface/type alias. A robust fix should resolve local object-shape declarations too. I’ll inspect extract_nested_type_bindings, declaration metadata, and whether a local type-shape registry already exists before adding narrowly scoped state.

  11. Assistant

    I’ll reproduce through the real CLI in /tmp (not by modifying tests). The project will export a reachable ResultState class and consume a typed $props() instance only from Svelte markup; JSON output will show whether pin is incorrectly reported. I’ll test both inline object annotations and a named Props interface to establish the required scope.

  12. Assistant

    The build toolchain initialized successfully, but the CLI crate has multiple binaries. I’ll rerun explicitly with --bin fallow; if --cwd is not the accepted flag, the CLI help will reveal the proper project-root option.

  13. Assistant

    The CLI uses the process working directory. I’ll run the built binary from the temporary project and capture JSON output.

  14. Assistant

    The end-to-end reproduction succeeds: both pin and truly unused unused are reported, proving the false positive. The named Props interface means merely supporting inline patterns is insufficient.

    I’ll add a module-local registry of object type shapes (interfaces and type aliases), then resolve object destructuring annotations against it. To keep behavior conservative, only statically named properties with direct class/interface type references will produce bindings; renames/defaults and nested patterns will be paired by property path, while rest/computed/unknown properties remain unbound. Before editing, I’m checking OXC node definitions and visitor ordering/finalization so declarations after use also work.

  15. Assistant

    Finalization matters: SFC code reads binding_target_names() immediately after visiting, before merge_into performs delayed resolution. I’ll therefore make destructured bindings resolve eagerly when possible and add them to the extractor’s normal finalization sequence for declaration-order independence, then explicitly finalize before SFC template maps are copied. This also avoids changing any public interface.

    Implementation pieces:

    1. Extract object-property type paths from both type literals and interface bodies.
    2. Pair destructuring property paths with local names (supports { prop: alias = value } and nested objects).
    3. Store candidates for named local shapes and resolve them after traversal.
    4. Finalize those candidates before SFC template scanning obtains the map.
    5. Bump extraction cache schema because emitted member_accesses changes.
  16. Assistant

    The cache is already at 102 due later changes, so I’ll bump it to 103 and document this semantic extraction change. I’m now applying the helper and extractor-state modifications, then will compile immediately to catch AST/type issues.

  17. Assistant

    The foundational state is in place. I’ll now wire collection and resolution into the visitor. I’ll also move candidate resolution before exported-instance recording in finalization so all downstream consumers see the completed map, not just Svelte.

  18. Assistant

    Compilation found one missing OXC type import in helpers.rs; the logic otherwise type-checked far enough to reach that declaration. I’ll add the explicit TSInterfaceBody import (the helper module does not wildcard-import AST types), then rerun formatting and compilation.

  19. Assistant

    The import grouping differed from my expected text, so the automated replacement did not apply. I’ll patch the actual import line directly and compile again.

  20. Assistant

    The extraction crate now compiles cleanly. I’ll bump/document the cache version, run the focused extraction tests, rebuild the CLI, and rerun the exact reproduction. The expected corrected output is only ResultState.unused; pin must disappear. I’ll then vary declaration order and destructuring aliases/defaults to validate edge cases.

  21. Assistant

    The real reproduction is fixed: only the deliberately unused method remains. My initial focused test filters used --exact without module-qualified names and therefore ran zero tests; I’ll correct that by using substring filters.

    Before broader tests, I’m validating:

    • the Props interface declared after $props() (delayed resolution),
    • renamed/defaulted destructuring,
    • inline object annotation,
    • shadowing remains handled by the existing template semantic analyzer.
  22. Assistant

    All edge-case reproductions now credit pin, leaving only unused, and both existing focused tests pass. I’ll review the full diff for accidental complexity/comment formatting and assess whether the implementation can be simplified. Then I’ll run all extraction tests and Clippy for the affected crate.

  23. Assistant

    The diff is clean. To minimize unrelated behavior, I’ll restore the preexisting finalization order for exported-instance recording; typed-destructuring still resolves before bound member accesses and SFC has explicit preparation, so the fix remains intact without changing export-sentinel timing. Then I’ll run the entire extraction test suite and Clippy.

  24. Assistant

    The full extraction suite (1,638 tests) and strict Clippy pass. One important Svelte 5 edge remains: $props<Props>() often carries the type on the call rather than on the binding:

    let { resultState } = $props<Props>();
    

    The current patch handles : Props = $props() but not this equivalent form. Since the expected behavior says the local “resolves to an instance,” I’ll extend the same conservative binding path to a single $props type argument, without treating arbitrary generic calls as destructured class instances. I’ll first inspect OXC call type-argument fields and existing Svelte rune detection conventions.

  25. Assistant

    OXC exposes exactly what is needed, and a public helper already extracts a referenced type name from a raw TSType. I’ll refactor the internal method to accept either annotation source, recognize only an identifier callee named $props, and use its sole type argument. Then I’ll compile and validate generic interface and inline generic forms through the CLI.

  26. Assistant

    Both $props<Props>() and $props<{…}>() forms now work, including aliasing and type declaration after the variable. The implementation remains conservative: it activates only for $props, and only object-shape properties whose types are statically named references become class targets.

    I’ll rerun formatting checks, all extraction tests, strict Clippy, and the original annotation-form end-to-end reproduction one final time. Then I’ll inspect the final diff/status and submit if clean.

  27. Assistant

    Verification is clean:

    • formatting and diff checks pass;
    • all 1,638 extraction tests pass;
    • strict Clippy passes;
    • the real CLI reproduction now reports only the intentionally unused method.

    I’ll do one final source diff scan for scope and then submit. Per the requested checklist:

    • Reproduced the reported error: yes; the temporary Svelte project initially reported both template-called pin and truly unused unused.
    • Confirmed the fix resolves it: yes; the same project now reports only unused, for annotation and generic $props forms.
    • Considered edge cases: yes; validated named/inline types, declarations after use, nested patterns, aliases/defaults, and both Svelte typing syntaxes; unsupported/computed properties remain conservatively unbound.
    • Ran affected existing tests: yes; all fallow-extract tests pass, along with strict Clippy and end-to-end CLI validation.

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