Skip to content
TheChatArchiveThe Chat Archive
x-ai/grok-4.5· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION service member referenced in an Angular external template is reported…

  1. User

    ISSUE DESCRIPTION

    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 angular plugin active, fallow dead-code reports a service method as an unused class member when its only reference is in an Angular HTML template (prop.method()), and the component property prop is initialized with the modern inject() 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 patternTemplate 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/core only needs to be listed in package.json so the angular plugin auto-activates — running npm install is optional (without it, fallow prints a "node_modules directory not found" warning but the finding still reproduces).

    1. Create package.json:

      {
        "name": "fallow-angular-template-repro",
        "version": "1.0.0",
        "private": true,
        "dependencies": {
          "@angular/core": "^20.0.0"
        }
      }
      
    2. Create .fallowrc.json:

      {
        "entry": ["src/main.ts"]
      }
      
    3. Create src/main.ts:

      import { ExampleComponent } from './example.component';
      
      console.log(ExampleComponent);
      
    4. Create src/example.service.ts:

      import { Injectable } from '@angular/core';
      
      @Injectable({ providedIn: 'root' })
      export class ExampleService {
        // Only referenced from example.component.html via an event binding.
        onValueChange(value: string): void {
          console.log(value);
        }
      }
      
    5. Create src/example.component.ts:

      import { Component, inject } from '@angular/core';
      
      import { ExampleService } from './example.service';
      
      @Component({
        selector: 'app-example',
        templateUrl: './example.component.html',
      })
      export class ExampleComponent {
        // Exposed to the template so the binding can call exampleService.onValueChange(...)
        readonly exampleService = inject(ExampleService);
      }
      
    6. Create src/example.component.html:

      <input (input)="exampleService.onValueChange($event.target.value)" />
      
    7. Run:

      npx fallow dead-code --config .fallowrc.json
      

    Actual output

    ── Unused Code ─────────────────────────────────────
    
    ● Unused class members (1)
      src/example.service.ts
        :6 ExampleService.onValueChange
      Class methods or properties never referenced outside their class
    
    ✗ 1 class member
    

    onValueChange is reported as unused even though it is referenced in example.component.html.

    Controls that isolate the root cause

    Keeping the template (input)="exampleService.onValueChange(...)" unchanged and only varying how exampleService is declared on the component:

    • Control A — constructor injection: replace the inject() field with constructor(public exampleService: ExampleService) {}. Result: ✓ No issues found.
    • Control B — inject() with an explicit type annotation: readonly exampleService: ExampleService = inject(ExampleService);. Result: ✓ No issues found.
    • Control C — new initializer: readonly exampleService = new ExampleService();. Result: ✓ No issues found.

    Only the untyped inject() initializer (the repro above) produces the false positive. This points at the component-property → service-type binding step: it resolves type annotations, constructor parameters, and new expressions, but not an untyped inject() initializer, so the template reference exampleService.onValueChange is never credited to ExampleService.

    Expected behavior

    A service member referenced from an Angular template via a component property should be credited as used when that property is initialized with inject() — the same way it already is for typed inject(), constructor injection, and new initializers. No unused-class-member finding should be reported in the repro above.

    Fallow version

    fallow 2.83.0

    Operating system

    macOS

    Configuration

    default
    

    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 start by exploring the repository structure and locating the Angular plugin logic that resolves template references to component properties.

  3. Assistant

    There's already an angular-inject-class-members fixture — I'll inspect it and the Angular plugin source next.

  4. Assistant

    rg is not found, let me use grep instead.

  5. Assistant

    Let me look at the angular plugin and the related tests, as well as template_usage.rs.

  6. Assistant

    Let me read the angular plugin and template usage code more carefully, and also the integration tests.

  7. Assistant

    I'll dig into template usage handling and how DI injection types get resolved.

  8. Assistant

    I found extract_angular_inject_target — reading that and how type bindings get produced.

  9. Assistant

    Now let me look at how extract_angular_inject_target is used around line 1886.

  10. Assistant

    Looking at how template usage credits members and how type bindings tie in.

  11. Assistant

    Let me look at how HTML templates are analyzed and how binding targets get from component to template analysis.

  12. Assistant

    Let me look at how angular template member access is credited - probably in the analyze phase for unused class members.

  13. Assistant

    The key is build_typed_instance_binding_targets in unused_members.rs — reading that next.

  14. Assistant

    Next I'll find where instance_bindings gets populated.

  15. Assistant

    The key function is extract_class_instance_bindings in helpers.rs.

  16. Assistant

    Root cause: extract_class_instance_bindings handles new but not untyped inject(). Checking related tests and how inject is detected elsewhere.

  17. Assistant

    Let me look at other tests related to inject and instance bindings.

  18. Assistant

    There are tests around line 3245-3315 for instance bindings, and angular inject tests at 1568. Let me read those.

  19. Assistant

    Let me also read the angular inject tests and the fixture for angular-template-inherited-members to understand the pattern.

  20. Assistant

    I'll review how typed instance bindings are used when processing template member accesses.

  21. Assistant

    There's also special handling for ANGULAR_TPL_SENTINEL. Let me find that.

  22. Assistant

    Let me read the section around 1439 where ANGULAR_TPL_SENTINEL is used.

  23. Assistant

    Continue reading about angular_tpl_chain_accesses

  24. Assistant

    Reading how resolve_typed_instance_chain_targets works with dotted access paths.

  25. Assistant

    I'll check helpers imports and whether type_name_root is available for handling inject type arguments.

  26. Assistant

    There's already Angular-related code in helpers.rs. Let me also check CallExpression is imported - it's not in the current imports! I need to add CallExpression or use Expression::CallExpression fully...

  27. Assistant

    There's type_name_root nested somewhere - it's in visit_impl. Let me check helpers for something similar.

  28. Assistant

    I'll look at extract_angular_signal_query for a similar pattern to follow.

  29. Assistant

    Let me also look for an existing issue fixture for this, and check fixtures structure.

  30. Assistant

    I understand the issue: extract_class_instance_bindings misses untyped inject(). Implementing the fix next.

  31. Assistant

    Checking how inline templates credit chained service members so we don't miss a path.

  32. Assistant

    Implementing the fix in extract_class_instance_bindings.

  33. Assistant

    Adding the helper function next to extract_class_instance_bindings.

  34. Assistant

    Adding a blank line for style, then building and reproducing.

  35. Assistant

    Fixing the botched edit.

  36. Assistant

    Creating a temporary reproduction and building the project.

  37. Assistant

    Let me build fallow with cargo.

  38. Assistant

    Build succeeded. Running the repro next.

  39. Assistant

    I need to check how to specify the working directory.

  40. Assistant

    Just cd to the directory and run with the config.

  41. Assistant

    The fix works. Verifying unused members still flag correctly and running related tests.

  42. Assistant

    Controls and integration tests next.

  43. Assistant

    Checking that the existing angular-inject fixture still works.

  44. Assistant

    Cleaning up diffs and verifying the final change.

  45. Assistant

    Confirming the bug reproduces without the fix:

  46. Assistant

    Recreating the repro to demonstrate the bug.

  47. Assistant

    Bug reproduced. Rebuilding with the fix and confirming resolution.

  48. Assistant

    Still failing after restoring the fix — checking whether the changes applied correctly.

  49. Assistant

    The source has the fix. Checking whether instance bindings extract correctly.

  50. Assistant

    Writing a temporary unit check for instance bindings.

  51. Assistant

    I'll add a temporary test, run it, then remove it.

  52. Assistant

    Extract is fine; tracing how templateUrl links the HTML into analysis.

  53. Assistant

    grep withdirectories keeps failing. Let me use find.

  54. Assistant

    Looking at how templateUrl becomes an import, then how angular_tpl_chain_accesses finds HTML via imports. Looking at the HTML parsing for member accesses:

  55. Assistant

    Checking how `

  56. Assistant

    Let me continue debugging.

  57. Assistant

    Checking when component class heritage and instance_bindings get recorded for exported classes.

  58. Assistant

    Looking at declarations for named exports path - declarations.rs.

  59. Assistant

    Removing the temporary test and carefully re-running the repro.

  60. Assistant

    Confirming remaining edge cases, then cleaning up.

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