Skip to content

[runtime] Adjust file/line information in fatal error messages to match compiler diagnostics #34665

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 1 commit into from
Nov 30, 2020

Conversation

lorentey
Copy link
Member

In debug configurations, fatal error messages include file & line number information. This update presents this information in a format matching the diagnostic conventions used by the compiler, which can be a slight productivity boost.

Code compiled with optimizations enabled (which is most production code) does not output this information, so it isn’t affected by this change.

Original format:

    Fatal error: A suffusion of yellow: file calc.swift, line 5

New format:

    calc.swift:5: Fatal error: A suffusion of yellow

Resolves rdar://68484891

…low diagnostic conventions

In debug configurations, fatal error messages include file & line number information. This update presents this information in a format matching the diagnostic conventions used by the compiler, which can be a slight productivity boost.

Code compiled with optimizations enabled (which is most production code) does not output this information, so it isn’t affected by this change.

Original format:

    Fatal error: A suffusion of yellow: file calc.swift, line 5

New format:

    calc.swift:5: Fatal error: A suffusion of yellow

Resolves rdar://68484891
@lorentey lorentey requested review from mikeash and jckarter November 10, 2020 21:24
Copy link
Contributor

@mikeash mikeash left a comment

Choose a reason for hiding this comment

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

Great idea!

@lorentey
Copy link
Member Author

@swift-ci test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 1a05171

@lorentey

This comment has been minimized.

@lorentey
Copy link
Member Author

@swift-ci test macOS platform

@lorentey
Copy link
Member Author

One wrinkle with this is that the file paths reported in these error messages use SE-0285’s #fileID, so they don’t directly map to local filesystem contents, even if the binary is running on the same host that built it.

This somewhat limits the usefulness of this change, but it doesn't entirely eliminate it -- e.g., with this change, Xcode can jump to the reported location by directly pasting it into its Open Quickly dialog.

@lorentey
Copy link
Member Author

I'm sort of apprehensive about tests I missed & tools I don't know about that expect messages in the original format, but let's try this and see what breaks.

@lorentey lorentey merged commit b0eafee into swiftlang:main Nov 30, 2020
@lorentey lorentey deleted the runtime-error-message-format branch November 30, 2020 19:46
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.

3 participants