Skip to content

Deserializer: better error message if types of referenced functions don't match #71612

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
Feb 15, 2024

Conversation

eeckstein
Copy link
Contributor

So far this resulted in an assert (in best case). Now a readable error is printed.

@eeckstein
Copy link
Contributor Author

@swift-ci test

fnName = decl->getNameStr();
}
fn->getModule().getASTContext().Diags.diagnose(fn->getLocation().getSourceLoc(), diag::deserialize_function_type_mismatch, fnName, fnType.getASTType(), type.getASTType());
exit(1);
Copy link
Member

Choose a reason for hiding this comment

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

Is there something we can do other than exit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't find anything better. We need to abort here immediately to not run into subsequent asserts/crashes.
I'm open to suggestions :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe llvm::report_fatal_error()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That also let it look like a compiler crash

if (auto *decl = dyn_cast_or_null<AbstractFunctionDecl>(dc->getAsDecl()))
fnName = decl->getNameStr();
}
fn->getModule().getASTContext().Diags.diagnose(fn->getLocation().getSourceLoc(), diag::deserialize_function_type_mismatch, fnName, fnType.getASTType(), type.getASTType());
Copy link
Contributor

Choose a reason for hiding this comment

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

This line is too long

fnName = decl->getNameStr();
}
fn->getModule().getASTContext().Diags.diagnose(fn->getLocation().getSourceLoc(), diag::deserialize_function_type_mismatch, fnName, fnType.getASTType(), type.getASTType());
exit(1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe llvm::report_fatal_error()?

…on't match

So far this resulted in an assert (in best case). Now a readable error is printed.
@eeckstein eeckstein force-pushed the function-type-mismatch-error branch from f7b24bb to 232a244 Compare February 15, 2024 09:14
@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein eeckstein requested a review from jckarter February 15, 2024 15:38
@eeckstein eeckstein merged commit bf3203f into swiftlang:main Feb 15, 2024
@eeckstein eeckstein deleted the function-type-mismatch-error branch February 15, 2024 20:25
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