Skip to content
TheChatArchiveThe Chat Archive
fable-5· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

unused-class-members FP: methods called only from Svelte <template> member expressions…

  1. User

    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.

  2. Assistant

    Let me look at the actual hister repro to understand how resultState is bound.

  3. Assistant

    Now let me check how the sfc template usage merges member accesses and how analysis resolves them for type-only imports:

  4. Assistant

    The analysis layer resolves imports regardless of type-only status. Now let me look at the extractor struct to add the new state:

  5. Assistant

    Now I'll implement. First, the helpers refactor:

  6. Assistant

    Now the extractor state in mod.rs:

  7. Assistant

    Now add the recorder + finalize methods. Let me add them near resolve_factory_call_candidates:

  8. Assistant

    Now wire it into the two finalize paths:

  9. Assistant

    Now the visit-time capture in visit_impl.rs. First the variable declaration hook:

  10. Assistant

    Now record the interface/alias property maps in visit_declaration:

  11. Assistant

    Now the SFC path — resolve pending destructures before binding_target_names() is read for template bound targets:

  12. Assistant

    Now a visitor-level test for the plain TS path. Let me check the test helpers:

  13. Assistant

    All pass. Since extraction output changes for unchanged sources (new member accesses), the extraction cache must be invalidated — let me bump CACHE_VERSION:

  14. Assistant

    Now run the full extract test suite and clippy:

  15. Assistant

    Now end-to-end validation against the actual hister repo:

  16. Assistant

    Passes in isolation. Let me confirm whether it's a pre-existing flake unrelated to my change:

  17. Assistant

    The earlier failure was a flake — full CLI suite passes on rerun. Final gates — fmt and workspace clippy:

  18. Assistant

    All gates pass. Let me document the new detection capability in .claude/rules/detection.md, following the project convention:

  19. Assistant

    The fix is complete and verified. Summary:

    Root cause

    The Svelte template scanner already resolves member expressions (resultState.pin(...)) through bound targets — a local → ClassName map — but that map was only populated from value-derived bindings (const counter = new Counter()). In hister, resultState is a Svelte 5 typed prop: let { resultState }: Props = $props() with a local interface Props { resultState: ResultState }. Typed object destructures were never registered, so template member calls on the prop resolved to nothing and the class methods reported as unused-class-member.

    Fix (all in crates/extract)

    • visitor/visit_impl.rs — visit_variable_declaration now handles ObjectPattern declarators with a type annotation via record_typed_object_destructure: inline type literals (: { svc: Service }) resolve immediately (with dotted aliases for nested object types, rename { counter: c } and default { pinned = false } unwrapping); type references (: Props) record a PendingTypedDestructure. visit_declaration now collects interface bodies and type-literal alias bodies into local_object_type_properties.
    • visitor/mod.rs — new finalize pass resolve_pending_typed_destructures resolves pending entries against the collected type maps (source-order independent), inserting into binding_target_names without overwriting more-precise value-derived bindings. Wired into both into_module_info and merge_into.
    • sfc.rs — the SFC pipeline runs the pending resolution before reading binding_target_names() for template bound targets (that read happens before merge_into's finalize); the method drains its queue so it's idempotent.
    • visitor/helpers.rs — refactored the TSTypeLiteral walker into shared collect_signature_type_bindings (interface bodies and type literals share the TSSignature shape) and added extract_type_alias_object_bindings.
    • cache/types.rs — CACHE_VERSION 102 → 103 (pre-fix cache entries lack the new member accesses).

    Unknown type references (imported Props, globals) resolve to nothing and drop silently — no fabricated accesses. Type-only class imports credit correctly because build_local_to_export_keys doesn't filter on is_type_only. Vue SFCs benefit automatically since the change is visitor-level.

    Verification

    • 7 new tests (3 SFC-level mirroring the hister shape incl. alias-after-use ordering; 4 visitor-level incl. the negative case) — all pass
    • Full workspace: extract 1645 ✓, CLI 2151 ✓ (one unrelated health::coverage yarn-sidecar test flaked in the parallel run; passes standalone and in module runs, on both clean and patched trees), cargo fmt --check ✓, cargo clippy --workspace --all-targets -D warnings ✓
    • End-to-end on asciimoo/hister with unused-class-members re-enabled: the four ResultState FPs (onOpen, pin, updateLabel, addSkipRule) are gone; the one remaining finding (WebSocketManager.isOpen) is a genuine true positive, confirming the fix doesn't blanket-credit

    One note: I attempted to document the new capability in .claude/rules/detection.md per project convention, but that file is edit-protected in this session — worth adding when this lands.

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