Skip to content

Switch to the "Swift" diagnostic style as the default #71722

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Feb 25, 2024

Conversation

DougGregor
Copy link
Member

The new "Swift" diagnostic style has been enabled for standard library builds for quite a while now, and we've addressed all of the issues we've seen with it. Turn it on by default.

There are a significant number of FileCheck-based tests in our test suite that are checking for the precise output of the LLVM diagnostic formatter, and do not pass with the new Swift one. Generalize those tests that are easy to generalize, so they pass with both, and force others to use the older formatter with -diagnostic-style llvm. If we need to switch back, we can leave the tests and switch the default back easily enough.

This resolves one old compiler crasher due to some poor Unicode handling in the older diagnostic formatter.

These tests are checking the printed outpout of the diagnostic formatter
in ways that change with the Swift formatter, but are not consequential.
These tests are using FileCheck to check the result of diagnostic
formatting in ways that don't match the new formatter. Force the old
formatter or, where possible, generalize so that they match both
formatters.
The old diagnostic formatter would crash on some Fix-Its involving
Unicode characters. The new one does not.
@DougGregor
Copy link
Member Author

swiftlang/swift-syntax#2501

@swift-ci please test

@DougGregor
Copy link
Member Author

@DougGregor
Copy link
Member Author

Python on Windows seems unhappy with some of the Unicode we are producing:

UnicodeEncodeError: 'charmap' codec can't encode character '\u2502' in position 219: character maps to <undefined>

Some versions of Python are unhappy with the Unicode the new diagnostic
formatter produces. For now, disable in one of the Python scripts where
we detect this.
@@ -2,5 +2,12 @@
// RUN: not %target-swift-frontend -typecheck %s 2> %t.errors
// RUN: %FileCheck %s <%t.errors
// CHECK-NOT: Program arguments:

// Note: extra newlines below ensure that context printing doesn't show the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment would be useful in the other tests that have multiple newlines as well. I was quite confused by them at first.

@DougGregor
Copy link
Member Author

@DougGregor
Copy link
Member Author

@slavapestov
Copy link
Contributor

@DougGregor Hahaha you finally fixed that compiler_crasher! Nice! Only one left...

@DougGregor DougGregor merged commit 0c9c734 into swiftlang:main Feb 25, 2024
@DougGregor DougGregor deleted the diagnostic-style-swift-default branch February 25, 2024 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants