Dart-code: Nonsensical error message on variable rename

Created on 24 Feb 2021  路  2Comments  路  Source: Dart-Code/Dart-Code

Describe the bug
Renaming date to now fails with:
_Usage of constructor "DateTime.now" declared in "date_time.dart" will be shadowed by renamed local variable._

test() {
  final date = DateTime.now();
}

To Reproduce
Steps to reproduce the behavior:

  1. Try the above

Expected behavior
now is a valid name, and shouldn't fail. It also doesn't shadow anything, as it seems to think.

Versions (please complete the following information):

  • VS Code version: 1.53.2
  • Dart extension version: 3.19.2
  • Dart/Flutter SDK version: >=2.10.0 <3.0.0
in editor in lsanalysis server is bug

All 2 comments

Thanks for the report! I can reproduce this - the message is coming from the language server so I've filed https://github.com/dart-lang/sdk/issues/45105. Thanks!

This has been fixed by https://github.com/dart-lang/sdk/commit/526e191a57b7399f0de3e09bd8f2bed6c066d0b1 and will be included in a future Dart/Flutter SDK update. Thanks!

Was this page helpful?
0 / 5 - 0 ratings