Skip to content
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

Add fatal_error() to the language #1402

Merged
merged 6 commits into from
Feb 28, 2024
Merged

Add fatal_error() to the language #1402

merged 6 commits into from
Feb 28, 2024

Conversation

WardBrian
Copy link
Member

@WardBrian WardBrian commented Feb 13, 2024

Closes #1393 .

Note that there is no way to parse this and also allow variables named exit, so this would immediately reserve the keyword. Based on a github search, I found only one package which uses exit as a variable name. If this is a serious concern we could consider different names like stop or something like fatal_error which is almost certainly unused.

Submission Checklist

  • Run unit tests
  • Documentation
    • If a user-facing facing change was made, the documentation PR is here: TBD

Release notes

Added fatal_error(), which is similar to reject() but rather than signaling an error which is recoverable, signals an error which should terminate execution immediately. fatal_error is now a reserved word.

Copyright and Licensing

By submitting this pull request, the copyright holder is agreeing to
license the submitted work under the BSD 3-clause license (https://opensource.org/licenses/BSD-3-Clause)

@WardBrian WardBrian added the feature New feature or request label Feb 13, 2024
@WardBrian WardBrian linked an issue Feb 13, 2024 that may be closed by this pull request
5 tasks
Copy link

codecov bot commented Feb 13, 2024

Codecov Report

Attention: Patch coverage is 31.42857% with 24 lines in your changes are missing coverage. Please review.

Project coverage is 89.87%. Comparing base (fa03ea2) to head (d567dfb).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1402      +/-   ##
==========================================
- Coverage   89.88%   89.87%   -0.02%     
==========================================
  Files          63       63              
  Lines       10513    10525      +12     
==========================================
+ Hits         9450     9459       +9     
- Misses       1063     1066       +3     
Files Coverage Δ
src/analysis_and_optimization/Mir_utils.ml 77.30% <ø> (ø)
src/analysis_and_optimization/Optimize.ml 93.23% <ø> (ø)
src/analysis_and_optimization/Pedantic_analysis.ml 93.30% <ø> (ø)
src/common/ICE.ml 0.00% <ø> (ø)
src/frontend/Ast.ml 68.90% <100.00%> (+0.13%) ⬆️
src/frontend/Info.ml 93.65% <100.00%> (+0.10%) ⬆️
src/middle/SizedType.ml 88.31% <ø> (ø)
src/middle/Stan_math_signatures.ml 98.01% <ø> (ø)
src/middle/Stmt.ml 79.36% <ø> (ø)
src/middle/UnsizedType.ml 80.20% <ø> (ø)
... and 17 more

@WardBrian WardBrian requested a review from nhuurre February 20, 2024 21:47
@nhuurre
Copy link
Collaborator

nhuurre commented Feb 21, 2024

I prefer fatal_error over exit. Note that in C++, std::exit(0) indicates a successful program completion.

@bob-carpenter
Copy link
Member

Good point. fatal_error sounds more descriptive and will match the logging statement that comes out as an error.

@WardBrian WardBrian changed the title Add exit() to the language Add fatal_error() to the language Feb 26, 2024
Copy link
Collaborator

@nhuurre nhuurre left a comment

Choose a reason for hiding this comment

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

Looks good, a couple of optional suggestions.

@WardBrian WardBrian merged commit 8bc6ba0 into master Feb 28, 2024
3 checks passed
@WardBrian WardBrian deleted the feature/exit branch February 28, 2024 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add exit() to the language
3 participants