Skip to content

Compiler - []= Return-Type False-Positive Error #61628

@RohitSaily

Description

@RohitSaily

dart --version: Dart SDK version: 3.10.0-247.0.dev (dev) (Thu Sep 25 13:09:08 2025 -0700) on "macos_x64"

Simple repro

final class AliasUser
{	Void operator []=(Object key, Object value){}
}
typedef Void=void;

The compiler emits the following error

main.dart:2:3: Error: The return type of the operator []= must be 'void'.
Try changing the return type to 'void'.
{       Void operator []=(Object key, Object value){}
        ^

I believe an alias of void should be acceptable as the return-type annotation for []=. Static analysis via VSCode does not report a warning. Only the compiler does.

Metadata

Metadata

Assignees

Labels

area-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions