service member referenced in an Angular external template is reported as unused when the…
- User
service member referenced in an Angular external template is reported as unused when the component property is initialized with
inject()(no explicit type annotation)What happened?
With the
angularplugin active,fallow dead-codereports a service method as an unused class member when its only reference is in an Angular HTML template (prop.method()), and the component propertypropis initialized with the moderninject()pattern without an explicit type annotation:readonly exampleService = inject(ExampleService);Fallow already credits template references through component properties for the other three DI/instance patterns — it is specifically the untyped
inject()initializer that is missed. The following all resolve correctly (no false positive); only the last one fails:Component property pattern Template prop.method()resolved?constructor(public svc: ExampleService) {}✅ yes svc: ExampleService = inject(ExampleService);(typed)✅ yes svc = new ExampleService();✅ yes svc = inject(ExampleService);(untyped)❌ no — false positive Because untyped
inject()is the idiomatic Angular style, this misfires on a very common real-world pattern.Reproduction
Minimal standalone repro.
@angular/coreonly needs to be listed inpackage.jsonso theangularplugin auto-activates — runningnpm installis optional (without it, fallow prints a "node_modules directory not found" warning but the finding still reproduces).-
Create
package.json:{ "name": "fallow-angular-template-repro", "version": "1.0.0", "private": true, "dependencies": { "@angular/core": "^20.0.0" } } -
Create
.fallowrc.json:{ "entry": ["src/main.ts"] } -
Create
src/main.ts:import { ExampleComponent } from './example.component'; console.log(ExampleComponent);
-
- Assistant
Now add the call-expression arm in the
PropertyDefinitionbranch: - Assistant
Now make
extract_angular_inject_targetvisible to sibling visitor modules: - Assistant
Bump the extract cache version since
class_heritage.instance_bindingsis persisted: - Assistant
Now build to check for compile errors:
- Assistant
Now create the test fixture:
- Assistant
Now add the integration test:
- Assistant
All tests pass. Let me verify the new test would actually fail without the fix, by temporarily neutralizing the new arm:
- Assistant
Confirmed: the test fails on pre-fix code and passes with the fix. Now run the broader checks:
- Assistant
Now verify end-to-end with the CLI against the repro fixture:
- Assistant
I accidentally dropped the
#[must_use]attribute — restore it: - Assistant
All four DI patterns from the issue table now resolve correctly. Cleaning up:
- Assistant
The full workspace test suite is still running in the background (it pipes output through a summary filter, so results appear only at completion). I'll report the final result when it finishes.
Summary of the fix so far:
Root cause: External Angular templates resolve
prop.method()member accesses throughClassHeritageInfo.instance_bindings, built byextract_class_instance_bindings(crates/extract/src/visitor/helpers.rs:615). That function handled typed constructor params, typed properties/getters, andnewinitializers — but not untyped initializers. (The inline-template path already handled via in , which is why only external templates misfired.)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.