dotnet/roslyn

Use of possibly unassigned field '_dummyPrimitive' (with sharplab)

Open

#67.212 aperta il 7 mar 2023

Vedi su GitHub
 (8 commenti) (1 reazione) (0 assegnatari)C# (4257 fork)batch import
Area-CompilersConcept-Diagnostic ClarityResolution-By Designhelp wanted

Metriche repository

Star
 (20.414 star)
Metriche merge PR
 (Merge medio 6g 17h) (256 PR mergiate in 30 g)

Descrizione

Version Used: All versions available on sharplab

Steps to Reproduce:

  1. write (non-async) Task method
  2. write if expression on some bool + resolving a nullable value, e.g. "msg.isFoo && msg.NullableId is not Guid id".
  3. write local (async) implementation method inside the first method that uses the non-nullable result (binds this+id) and call it. ...Error manifests if the result of the nullable expression is used inside the local method, e.g. "Console.Write(id);"

A minimal repro, with source-code provided, is ideal. Using sharplab is preferred for compiler/language issues whenever possible: https://sharplab.io/#v2:C4LgTgrgdgNAJiA1AHwAICYAMBYAUBgRj1UwAJUCBWAbj2IGZz1yCB2PAbz1J/MYoBs5IQFkAhgEsoACgCU3Xl1y8VpAG5iwpALYBTAM76xAc12kAvKSi6A7qREGjpgCLAA9nNrLVPBT4kAZqTSeoYmugB0EvoAYm5upABkiTqO4VFw4gCeAEZm0VZuwKQA4hAScKQV8t4+Sj4+FACc0gBEgDwbgCD7rbJeDaqorMIRAMJu2gAOADa6wLpwqAJ9DQC+fqrrKoOkAIL6WVAAxgCSk1Oem7yXPKgAHMK7+0en03LXpPX9vIHBoU6R0TibhqX0U736zWk1WWoLWtVUcJUcLhxGYDjCLncnHWqEYOXiUyqsXiH1MwGoiN4uNK5TgAH4qpkxLkzBwyRS8CsgA

Diagnostic Id: CS0170

Expected Behavior: No error.

Actual Behavior: Error on hidden compiler variable.

Guida contributor