[AST][Diagnostics] Reading DiagnosticTransaction's hasErrors() has unexpected side effects
#74175
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
diagnostic engine
Area → compiler → AST: The `DiagnosticEngine` class
Description
the implementation of
DiagnosticTransaction'shasErrors()method calls through to the underlying engine state'sdetermineBehavior()method. that method has side-effects in the case that its argument is an error, in which cases it mutates the relevant error flags. this leads to confusing behavior where readinghasErrors()on an open transaction can affect the behavior of the parent diagnostic engine.Reproduction
somewhere in the compiler (i tested in TypeCheckConstraints.cpp), do something like the following:
Expected behavior
i would expect either no side-effects when calling an open transactions
hasErrors()or if the transaction is aborted, the error state should be reset to what it originally was when the transaction was opened.Environment
swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0
Additional information
associated forums post
The text was updated successfully, but these errors were encountered: