-
-
Notifications
You must be signed in to change notification settings - Fork 313
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
Replace panic! with internal-error! in ast crate #4297
Replace panic! with internal-error! in ast crate #4297
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.
@ayazhafiz or @folkertdev, could you take a look at this? Some of these cases look like the might be user_error!
instead of internal_error!
. I just don't know this code well enough.
@@ -188,7 +189,7 @@ fn canonicalize_field<'a>( | |||
} | |||
|
|||
Malformed(_string) => { | |||
panic!("TODO canonicalize malformed record field"); | |||
internal_error!("TODO canonicalize malformed record field"); |
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.
Can we making things that say TODO
into todo!
?
@@ -2064,7 +2065,7 @@ pub mod test_constrain { | |||
|
|||
assert_eq!(actual_str, expected_str); | |||
} | |||
Err(e) => panic!("syntax error {:?}", e), | |||
Err(e) => internal_error!("syntax error {:?}", e), |
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.
I am not very fimilare with this code, but I wonder if this is a user_error!
that just doesn't have a pretty message yet.
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.
I think using internal_error
is still okay here, things that don't exit well to the user are internal errors to the compiler.
crates/ast/src/lang/core/def/def.rs
Outdated
@@ -574,7 +574,7 @@ fn canonicalize_pending_def<'a>( | |||
.. | |||
} => { | |||
if arguments.len() != type_arguments.len() { | |||
panic!("argument number mismatch"); | |||
internal_error!("argument number mismatch"); |
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.
Same with this and the errors below in this file. They might really be user_error!
crates/ast/src/solve_type.rs
Outdated
self.0 | ||
.get_mut(rank.into_usize()) | ||
.unwrap_or_else(|| panic!("Compiler bug: could not find pool at rank {}", rank)) | ||
self.0.get_mut(rank.into_usize()).unwrap_or_else(|| { |
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.
nit: remove the Compiler bug:
prefix here and below
crates/ast/src/module.rs
Outdated
@@ -20,14 +21,16 @@ pub fn load_module(src_file: &Path, threading: Threading) -> LoadedModule { | |||
match loaded { | |||
Ok(x) => x, | |||
Err(roc_load::LoadingProblem::FormattedReport(report)) => { | |||
panic!( | |||
internal_error!( |
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.
Also, here, not sure if this should technically be a user_error!
Thanks so much for doing this! These are the small steps to eventually getting a robust and fuzzable compiler. Makes it clear to the end users when they should to file bugs. |
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.
LGTM after @bhansconnect 's comments are addressed
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.
Thanks for doing this. 2 more minor changes.
@@ -188,7 +189,7 @@ fn canonicalize_field<'a>( | |||
} | |||
|
|||
Malformed(_string) => { | |||
panic!("TODO canonicalize malformed record field"); | |||
internal_error!("todo! canonicalize malformed record field"); |
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.
Oh, this was a slight misunderstanding. I meant todo!("canonicalize malformed record field")
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.
Oh, yes of course.
crates/ast/src/solve_type.rs
Outdated
.get(rank.into_usize()) | ||
.unwrap_or_else(|| panic!("Compiler bug: could not find pool at rank {}", rank)) | ||
self.0.get(rank.into_usize()).unwrap_or_else(|| { | ||
internal_error!("Compiler bug: could not find pool at rank {}", rank) |
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.
nit: remove Compiler bug:
here as well.
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.
Sorry for being so slow about this. The last few weeks have been quite hectic for me. Looks great!
Hi,
I replaced
panic!
withinternal_error!
.I started with only
panic!
and only inside theast
crate to keep this PR small.Related to #2046