Closed DmitryVasilevsky closed 1 year ago
- There's a compiler option to turn any diagnostic code from a warning to an error. (Most compilers support this.)
To that end, see for example the WarningsAsErrors feature of the C# compiler or the Lint Levels feature of the Rust compiler. It's a common compiler pattern to allow someone to set all warnings, warnings of a specific class, or individual warnings identified by code to be treated as errors for a given compilation. I think that pattern is more standard and flexible than duplicating the codes among both the error and warning enum.
An alternative approach has been implemented. https://github.com/microsoft/qsharp-compiler/pull/1594
Adding option TreatCapabilityErrorsAsWarnings (command line argument treat-capability-errors-as-warnings). When set, it will instruct compiler to emit warnings instead of errors for target capabilities. Affected diagnostics:
UnsupportedResultComparison = 5023 ResultComparisonNotInOperationIf = 5024 ReturnInResultConditionedBlock = 5025 SetInResultConditionedBlock = 5026 UnsupportedCallableCapability = 5027 UnsupportedClassicalCapability = 5028
Current approach propagates this flag into F# type Target in module Analyzer. Then the flag is used to issue errors or warnings. (Alternative approach is to convert specific errors to warnings in C# code after they are collected).