Skip to content

[lldb] Improve wording of Swift expression parser error messages (NFC) #10399

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
Apr 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -738,13 +738,14 @@ bool SwiftUserExpression::Parse(DiagnosticManager &diagnostic_manager,
auto ts_or_err = target->GetScratchTypeSystemForLanguage(
lldb::eLanguageTypeSwift, /*create_on_demand=*/true);
if (!ts_or_err)
return error("could not create a Swift scratch context: ",
return error("could not create a Swift scratch typesystem",
llvm::toString(ts_or_err.takeError()).c_str());
m_swift_scratch_ctx =
std::static_pointer_cast<TypeSystemSwiftTypeRefForExpressions>(
*ts_or_err);
if (!m_swift_scratch_ctx)
return error("could not create a Swift scratch context: ", "unknown error");
return error("could not create a Swift scratch typesystem",
"unknown error");
// Notify SwiftASTContext that this is a Playground.
if (m_options.GetPlaygroundTransformEnabled())
m_swift_scratch_ctx->SetCompilerOptions("");
Expand All @@ -765,12 +766,13 @@ bool SwiftUserExpression::Parse(DiagnosticManager &diagnostic_manager,
std::static_pointer_cast<SwiftASTContextForExpressions>(swift_ast_ctx);

if (!m_swift_ast_ctx)
return error("could not create a Swift AST context");
return error("could not initialize Swift compiler",

Choose a reason for hiding this comment

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

I think there's a space missing here, it will print "compilerrun"

Copy link
Author

Choose a reason for hiding this comment

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

No, these are separate messages.

"run 'swift-healthcheck' for more details");

Choose a reason for hiding this comment

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

These are user facing right? Running swift-healthcheck won't produce anything useful to the user, right? I'd change it to run swift-healthcheck and file a bug with the file.

Copy link
Author

Choose a reason for hiding this comment

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

It is user-facing, but it contains, for example compiler errors that users are expected to be familiar with.


if (m_swift_ast_ctx->HasFatalErrors()) {
m_swift_ast_ctx->PrintDiagnostics(diagnostic_manager);
LLDB_LOG(log, "Swift AST context is in a fatal error state");
return false;
return error("Swift AST context is in a fatal error state",
"run 'swift-healthcheck' for more details");
}

// This may destroy the scratch context.
Expand Down