-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Avoid using std::process::exit(0)
in ProjectCompiler::compile
#10328
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ty, yeah we should def remove this.
this is legacy from when this existed directly in foundry and we wanted to exit early.
not sure if this has side-effects in foundry now,
we should check before we merge this @grandizzy
@Pronoss thank you, please fix compilation errors |
@grandizzy |
After some investigation, I've decided to revert the change and keep the original std::process::exit(0) call. While avoiding exit(0) would be more idiomatic in Rust, replacing it with a return value like Ok(ProjectCompileOutput::default()) isn't currently feasible without introducing a Default bound on C::Language, which breaks compatibility with downstream code (e.g., foundry-cli fails to compile with E0277). I explored alternative approaches, including returning an Option or a custom Err, but they would require a wider refactor across the entire call chain. Given that, I've opted to keep the current behavior and leave a // TODO: Avoid process::exit(0) comment in the code for future cleanup when a broader change is more appropriate. Should I add a more detailed comment in the code next to the exit(0) explaining these issues? |
@Pronoss do I get this right that you propose to keep current behavior and only improve TODO comment? If so, can you draft the comment here to check if it makes sense? thanks! |
@grandizzy Yes, that’s correct — I’ve decided to keep the current |
This pull request replaces a call to
std::process::exit(0)
in theProjectCompiler::compile
method with a properOk(ProjectCompileOutput::new())
return.PR Checklist