ISSUE DESCRIPTION unused-class-members FP: methods called only from Svelte <template>…
- 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 exampleresultState.pin(...)in markup) are reported asunused-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.addSkipRuleare each invoked from.sveltetemplates (resultState.pin(...)inResultActionsMenu.svelte) yet reported unused. The repo currently setsrules.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 usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto 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-$
Assistant
Let me start by exploring the repository structure to understand what we're working with.
Assistant
This is a Rust project (Fallow linter). Let me explore the structure further.
Assistant
There's a
sfc_templatedirectory. Let me explore it.Assistant
Now let me look at the svelte.rs and vue.rs files to understand the
bound_targetsconcept and member access tracking.Assistant
The file is long. Let me look at the shared.rs file for the bound_targets handling.
Assistant
Let me look at the
template_usage.rsfile to understand the bound_targets logic.Assistant
Now let me find where
bound_targetsis computed and howcollect_template_usage_with_bound_targetsis called.Assistant
Let me look at
binding_target_namesto understand what bound targets are detected.Assistant
Let me look at the
apply_template_usagefunction in sfc.rs.Assistant
Let me look at how binding_target_names collects class instances in visit_impl.rs.
Assistant
Let me look at how
new SomeClass()creates a binding_target_names entry. Let me search for the relevant code.Assistant
Let me look at how member_accesses flow into unused-class-members analysis.
Assistant
Let me look at the false_positive_fixes.rs integration test file.
Assistant
Let me look at how member_accesses are matched against class members in unused_members.rs.
Assistant
Let me look at the main accessed_members logic around line 1540.
Assistant
Let me look at existing Svelte integration tests to understand the test setup.
Assistant
There's an existing test that works for attribute handler case. Let me write a reproduction to check the markup expression case. First, let me see the
parse_sfchelper.Assistant
Let me create a temporary reproduction test to check the markup expression case.
Assistant
Let me check the tests module structure.
Assistant
I need to register my repro module. Let me check the tests mod.rs and add it temporarily.
Assistant
Now let me check the crate name for the extract crate (fallow_extract or fallow-extract).
Assistant
Both simple cases pass. The issue must involve a more specific pattern. Let me look at the full svelte.rs apply_tag and apply_markup_tag functions.
Assistant
Let me look at the helper functions
merge_markup_brace_usage,merge_attribute_value_usage, anddirective_binding_name.Assistant
The extraction layer works. The issue may be in the core analysis layer. Let me write a full integration test reproducing the end-to-end flow. Let me look at the integration test infrastructure.
Assistant
There's a Vue fixture for this. Let me find the vue-project fixture and the Counter class setup.
Assistant
Let me check if there's a svelte-project fixture with a similar pattern.
Assistant
The svelte-project fixture has the same pattern. Let me check the existing tests for this fixture.
Assistant
Let me search the changelog and repo for references to this issue or hister.
Assistant
The existing tests use
onclick={() => counter.bump()}(handler) and{counter.value}(property access). The issue is about method CALLS in markup text. Let me create a temp fixture to test the full integration flow end-to-end.Assistant
Now let me look at the common test helpers to write an integration test.
Assistant
Let me check how the integration_test module is organized.
Assistant
Let me create a temporary integration test and register it.
Assistant
The
new ResultState()pattern works end-to-end. The bug must be a different instantiation pattern. Let me examine the typed-instance-binding mechanism, since the issue says "when<local>resolves to an instance of the class".Assistant
This
propagate_accesses_through_typed_instance_bindingshandles the case where a class has a typed member likeservice: MyServiceandthis.service.foo()is called. It usesclass_heritage.instance_bindings. This is for the Angular DI case where constructor-injected services have types.Let me look at the rest of propagate_accesses_through_typed_instance_bindings.
Assistant
Let me look at how
INSTANCE_EXPORT_SENTINELis emitted - this seems relevant for exported instances.Assistant
Let me look at how the INSTANCE_EXPORT_SENTINEL is emitted in visitor/mod.rs around line 470-510.
Assistant
Let me check whether the SFC path calls the finalize steps like
record_exported_instance_bindings. Let me look atmerge_intoand the finalize flow.Assistant
The SFC path handles in-file instances. Now let me test the SINGLETON pattern: an exported instance in a
.tsfile imported into Svelte. Let me update my fixture.Assistant
Interesting! With the singleton pattern, NOTHING is reported unused (including
unusedMethod) - that's over-crediting. Let me look at the fullpropagate_accesses_through_instance_exports.Assistant
Let me test the Svelte 5 runes hypothesis -
let resultState = $state(new ResultState()). Let me update the fixture.Assistant
I've reproduced the FP! With Svelte 5 runes
let resultState = $state(new ResultState()), the methods are reported as unused because$state(new ResultState())doesn't registerresultState → ResultStatein binding_target_names. Let me look at the visitor's variable declaration handling to find the right fix.Assistant
There's a
try_extract_factory_new_classhelper for wrapper patterns. Let me look at it.Assistant
I've reproduced the FP. Now let me check if there's existing handling for Svelte runes or type-preserving wrappers.
Assistant
No existing rune handling. Let me check the oxc
Argumentenum variants to design the helper correctly.Assistant
Argument::as_expression()exists. Let me look at how it's used and check the existing helper file structure.Assistant
Let me look at the helpers.rs imports and the existing factory helper signature to design a new helper.
Assistant
Let me verify the
Argument::as_expressionmethod and look at how the existing factory helper handles arguments.Assistant
Argumentinherits allExpressionvariants includingNewExpression, andas_expression()exists. Now let me implement the fix. First, add a helper in helpers.rs.Assistant
Let me add
CallExpressionto the helpers.rs imports and add the new helper function.Assistant
Now let me add the new helper function after the factory helper. Let me view the area after
extract_new_class_from_return_body.Assistant
Now let me add the call site in visit_impl.rs after the array-destructure factory block.
Assistant
Let me view the array-destructure block to find the insertion point.
Assistant
Now let me build and run my reproduction test.
Assistant
The fix works for
$state. Let me also test Vueref(new Counter())and verify I haven't broken existing tests. Let me extend my temp test with a Vue ref case.Assistant
Both Svelte
$stateand Vuerefnow work, and unused methods are still reported. Let me run the extract crate tests and broader SFC tests to check for regressions.Assistant
All extract tests pass. Now let me run the core SFC integration tests.
Assistant
Now let me run the unused_members unit tests and the broader integration suite.
Assistant
All 525 integration tests pass. Let me run the core lib tests and the full false_positive_fixes suite.
Assistant
Let me check how
resolve_bound_member_accesseshandles chained access to ensure my fix doesn't mis-credit.valuefor refs.Assistant
Let me look at
resolve_bound_object_nameto understand chain handling.Assistant
Let me check how the visitor collects chained member accesses for
counter.value.bump().Assistant
Let me check
static_member_object_name.Assistant
Let me also test the prop-based scenario (
export let resultState: ResultState) to see if it's also an FP and whether my fix covers it.Assistant
The general approach risks a
.valuefalse negative for Vueref(which returnsRef<T>, needing.value). Svelte$statereturns the instance directly. Let me make the helper use an allowlist of wrappers that return the instance directly (no.value/$indirection). Let me update the helper.Assistant
Now let me update the temp Vue fixture to use
reactive(in the allowlist) instead ofref.Assistant
All pass. Let me run the full extract and core test suites with the allowlist to confirm no regressions.
Assistant
Let me also check the typed-local case (
let resultState: ResultStatewith no init), which might be another FP pattern. Let me look atrecord_typed_bindingand how typed bindings flow.Assistant
instance_bindingsis a Vec<(String, String)> onClassHeritageInfo(for class fields).record_typed_bindingis for class members (constructor params / class fields). Let me checkrecord_typed_bindingto see if it ALSO handles module-level typed locals.Let me look at
record_typed_binding.Assistant
record_typed_bindingalready handles typed locals (that's why the prop case works pre-existing). My fix fills exactly the$state/wrapper gap. Let me run the graph and cli test suites to be safe, since the visitor is shared.Assistant
One cli test failed -
resolves_yarn_sidecar_without_node_modules_bin. This seems unrelated to my change. Let me verify it's pre-existing by stashing my changes.Assistant
When run in isolation (original code) it passes. Let me run the yarn test in isolation WITH my changes to check if it's a test-ordering/environment issue, not my change.
Assistant
It passes in isolation with my changes too — it's a flaky test-ordering issue, not my change. Let me confirm by re-running the full cli lib suite.
Assistant
Confirmed flaky — now passes. Let me run clippy and fmt checks since the repo enforces them.
Assistant
The only clippy warnings are from my temp test file (which I'll remove). My actual changes are clean. Now let me clean up all temporary test files and fixtures.
Assistant
Only my two source files are modified. Let me re-run clippy and fmt to confirm clean.
Assistant
Clippy and fmt clean. Let me re-run the key test suites after cleanup to confirm everything passes.
Assistant
Let me do a final end-to-end verification with a temp fixture, then remove it.
Assistant
Let me fix the module registration - I'll place it after
mod common;.Assistant
The fix works end-to-end.
onOpen,pin,addSkipRuleare credited;unusedMethod(andupdateLabelwhich isn't called) correctly reported. Now let me clean up the temp verification files.Assistant
Only my two source files are modified. Let me do a final review of the diff.
Assistant
The comment in visit_impl.rs mentions
ref(new C())which is actually excluded by my allowlist. Let me fix the comment to be accurate.Assistant
Clean. Let me run the final test suite to confirm.
Assistant
All tests pass. Let me run the core lib tests once more and view the final diff.
Assistant
All tests pass. Let me do a final review of the complete diff.
Assistant
The CHANGELOG mentions cache version bumps for similar fixes (since
member_accessesoutput changes). My fix changesbinding_target_names→member_accessesoutput, so I should bump the extraction cache version. Let me find it.Assistant
I should bump the extraction cache version since my fix changes the extracted
member_accessesoutput. Let me bump to 103.Assistant
Let me check if any tests assert on the cache version number that might break with the bump.
Assistant
Let me check the extract cache tests that might reference the version number.
Assistant
The cache tests use the constant, not hardcoded values, and my change doesn't alter struct sizes. Let me run the extract cache tests and full suite to confirm.
Assistant
Let me run the core caching integration tests (they test cache round-trip/version invalidation).
Assistant
All caching tests pass. Let me run fmt and clippy once more on the final changes.
Assistant
Let me do a final full test run to confirm everything is green after all changes.
Assistant
All green. Let me review the complete final diff.
Assistant
Let me do a final check that no temporary files remain and confirm the final state.
Assistant
Only the 3 source files are modified, no temp files remain. Let me run a couple more dependent-crate tests (lsp, config) to be thorough since the visitor is shared.
Assistant
fallow-lspis a binary crate. Let me run its tests.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →