Skip to content

Diagnostics stop showing when some kinds of errors are produced (ex: invalid_constant with a missing required argument produces an invalid range) #5359

@klukshu

Description

@klukshu

Describe the bug

there is a specific file (lib/auth/auth_bloc.dart) where changes will not trigger analysis (ie. if I delete a semicolon, nothing happens). Code actions will suggest fixes for the problems, but the UI does not show the error itself.

I have opened the file as a txt just to make sure there weren’t any hidden annotations, and there are no files in the excluded folders for both user and workspace.

I have spent quite some time trying to solve this, and irritatingly copy and pasting the code into a new file even as separate blocks does not work. Running flutter analyze and dart analyze command in the terminal will notice the changes.

If I restart my computer, any errors that exist in the file are found: they are in the problems tab, and the visual ques in the editor work as expected. However, if I then introduce an error to the file or fix an existing error the changes are not reflected in the problems tab.

If I run analyze in the terminal, fixed problems no longer appear, but the error message persists in the problem tab. Restarting the language server will erase all of the problems, regardless of if they exist or not; in both the visual ques and the problems tab. The most baffling part is that for every other file the dev tools operate normally. And I have copied over the folder to a new project and the errors persist, which can be seen here, but i have scoured the files for anything that would tell the analyzer to ignore it and I cannot find any hidden files.

I have yet to test on a clean install of vs code and I copied the Auth folder over within vs code; I have not completely ruled out my VS code install and config being a problem. I have debugged to the point that to do so any further systematically would require a greater understanding of the internals of dart-code than I possess.

Restarting the following proved futile:

  • dart analyser
  • the language server
  • vs code
  • my computer

To Reproduce
This is a sneaky bug I am not sure how i broke it because it took a while for me to notice. I can copy the file into a new project and the behaviors persist, in identical fashion, which I will call reproduction. That copy is available here: https://github.com/klukshu/inconsistent_code_analysis.

Expected behavior
When i make an error (ie, delete a semi colon), i would expect that it would show up in the problems tab and a visual cue to appear on screen but it does not.

I am curious if this problem will persist on other people's machines, I have attached a bare-bones repository, with the problematic file and all it's direct dependencies, no effort was made to make the program buildable. The behavior of auth_bloc.dart in this project is the same as in the project I copied it over from.

Workspace Environment
Dart Code extension: 3.100.0
Flutter extension: 3.100.0 (activated)

App: Visual Studio Code
App Host: desktop
Version: linux 1.95.3

Workspace type: Flutter (LSP)
Workspace name: inconsistent_code_analysis

Dart (3.5.1): redacted
Flutter (3.24.1): redacted (Linux (linux-x64/linux))

Output from 'dart info'

If providing this information as part of reporting a bug, please review the information
below to ensure it only contains things you're comfortable posting publicly.

General info

Project info

  • sdk constraint: '^3.5.1'
  • dependencies: bloc, cupertino_icons, flutter
  • dev_dependencies: flutter_lints, flutter_test

Process info

Memory CPU Elapsed time Command line
68 MB 0.1% 04:16 dart devtools --machine --allow-embedding --dtd-uri ws:/gg2YLdGUIGhJSDxj
574 MB 2.5% 04:16 dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.100.0
80 MB 0.1% 04:16 dart tooling-daemon --machine
Output from 'flutter doctor'
[✓] Flutter (Channel stable, 3.24.1, on Linux Mint 22 6.8.0-49-generic, locale en_CA.UTF-8)
    • Flutter version 3.24.1 
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5874a72aa4 (3 months ago), 2024-08-20 16:46:00 -0500
    • Engine revision c9b9d5780d
    • Dart version 3.5.1
    • DevTools version 2.37.2

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at 
    • Platform android-35, build-tools 35.0.0
    • ANDROID_HOME = 
    • Java binary at: 
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✗] Linux toolchain - develop for Linux desktop
    ✗ clang++ is required for Linux development.
      It is likely available from your distribution (e.g.: apt install clang), or can be downloaded from https://releases.llvm.org/
    ✗ CMake is required for Linux development.
      It is likely available from your distribution (e.g.: apt install cmake), or can be downloaded from https://cmake.org/download/
    ✗ ninja is required for Linux development.
      It is likely available from your distribution (e.g.: apt install ninja-build), or can be downloaded from https://github.com/ninja-build/ninja/releases
    • pkg-config version 1.8.1
    ✗ GTK 3.0 development libraries are required for Linux development.
      They are likely available from your distribution (e.g.: apt install libgtk-3-dev)

[✓] Android Studio (version 2024.1)
    • Android Studio at /usr/local/android-studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)

[✓] VS Code (version 1.95.3)
    • VS Code at /usr/share/code
    • Flutter extension version 3.102.0

[✓] Connected device (1 available)
    • Linux (desktop) • linux • linux-x64 • Linux Mint 22 6.8.0-49-generic

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 2 categories.

i was also using usernamehw.errorlens but enabling and disabling it did not change the behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    in editorRelates to code editing or language featuresin lsp/analysis serverSomething to be fixed in the Dart analysis serveris bugrelies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become available

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions