Skip to content

[dot-shorthands] inconsistent false positive const_constructor_param_type_mismatch (VSCode) #61209

@RohitSaily

Description

@RohitSaily

this is not a flutter issue but the analysis problem is reproduced by invoking constructors from flutter

problem

controller.selection=.fromPosition(const .new(offset:1));

the const expression const .new(offset:1) gets flagged as error const_constructor_param_type_mismatch when it shouldn't, the default inputs to the constructor and the explicitly specified value 1 are all correct

for some reason, the error does not show up immediately. running the VSCode palette command Dart: Restart Analysis Server causes it to show up. if the expression is edited and then the file is saved the error goes away. after some time or by forcing reanalysis, it reappears

minimal reproduction

[1] pubspec.yaml
name: 'example'
publish_to: 'none'
environment:
  sdk: '^3.10.0-28.0.dev'
  flutter: '^3.33.0-1.0.pre-1146'
dependencies:
  flutter:
    sdk: 'flutter'
[2] analysis_options.yaml
analyzer:
  enable-experiment:
    - dot-shorthands
[3] main.dart
import 'package:flutter/widgets.dart';
void f(TextEditingController controller)
{	controller.selection=.fromPosition(const .new(offset:1));
}
[4] run VSCode palette command Dart: Restart Analysis Server (or otherwise trigger expression analysis)

editing and receiving errors via VSCode

dart --version

Dart SDK version: 3.10.0-28.0.dev (dev) (Thu Jul 24 09:03:49 2025 -0700) on "macos_x64"

flutter --version

Flutter 3.33.0-1.0.pre-1146 • channel main • https://github.com/flutter/flutter.git
Framework • revision 7de7baf2f1 (2 days ago) • 2025-07-27 18:01:28 -0400
Engine • hash c4f6c31864263c8d82ddc565c84501646c73138a (revision 7de7baf2f1) (36 hours ago) • 2025-07-27
22:01:28.000Z
Tools • Dart 3.10.0 (build 3.10.0-28.0.dev) • DevTools 2.48.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.feature-dot-shorthandsImplementation of the dot shorthands feature.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