Skip to content

Invalid argument(s): Unexpectedly not indexed: T #60745

@Fabricio-191

Description

@Fabricio-191

Code:

class CustomType<T> {
  static CustomType<T> staticProperty;
}

final MY_TYPE = CustomType.staticProperty;

Expected behavior: "Static members can't reference type parameters of the class.
Try removing the reference to the type parameter, or making the member an instance member." on static CustomType<T> staticProperty; line

Actual behavior: Dart analyzer crashes with log:

[9:54:33 PM] [Analyzer] [Error] [Invalid argument(s): Unexpectedly not indexed: T
#0      _LocalElementIndexer.[] (package:analyzer/src/summary2/bundle_writer.dart:1316:10)
#1      ResolutionSink._indexOfElement (package:analyzer/src/summary2/bundle_writer.dart:900:27)
#2      ResolutionSink._writeElement (package:analyzer/src/summary2/bundle_writer.dart:935:24)
#3      ResolutionSink.writeElement (package:analyzer/src/summary2/bundle_writer.dart:815:7)
#4      ResolutionSink.writeType (package:analyzer/src/summary2/bundle_writer.dart:875:7)
#5      ResolutionSink.writeType (package:analyzer/src/summary2/bundle_writer.dart:858:11)
#6      BundleWriter._writeTopLevelVariableElement (package:analyzer/src/summary2/bundle_writer.dart:671:21)
#7      BundleWriter._writeList (package:analyzer/src/summary2/bundle_writer.dart:48…

dart --version: Dart SDK version: 3.7.2 (stable) (Tue Mar 11 04:27:50 2025 -0700) on "windows_x64"

I tried deleting everything inside my analysis_options.yaml but it didn't change anything

Note: if you delete the line final MY_TYPE = CustomType.staticProperty; it works as expected, so probably when dart analyzer tries to determine the type of the MY_TYPE variable something weird happens

Note 2: this issue seems somewhat similar to #48096

Log: log-562c.txt

Activity

added
area-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.
on May 18, 2025
FMorschel

FMorschel commented on May 19, 2025

@FMorschel
Contributor
added
model-crashesCrashes in the analyzer or CFE
area-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.
and removed
area-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.
on May 19, 2025
scheglov

scheglov commented on May 19, 2025

@scheglov
Contributor

The analyzer / analysis server should not crash of course.

But I will note that this code has a compile-time error, you cannot reference type parameters inside static members.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.model-crashesCrashes in the analyzer or CFE

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @scheglov@Fabricio-191@FMorschel

        Issue actions

          Invalid argument(s): Unexpectedly not indexed: T · Issue #60745 · dart-lang/sdk