mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 04:08:19 +00:00
chore: replace panic! with internal_error
This commit is contained in:
parent
f6221fb9e9
commit
8bf888a5e6
8 changed files with 27 additions and 17 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -3741,6 +3741,7 @@ dependencies = [
|
|||
"quickcheck",
|
||||
"quickcheck_macros",
|
||||
"roc_collections",
|
||||
"roc_error_macros",
|
||||
"roc_module",
|
||||
"roc_region",
|
||||
]
|
||||
|
|
|
@ -1378,31 +1378,31 @@ pub fn canonicalize_expr<'a>(
|
|||
// Below this point, we shouln't see any of these nodes anymore because
|
||||
// operator desugaring should have removed them!
|
||||
bad_expr @ ast::Expr::ParensAround(_) => {
|
||||
panic!(
|
||||
internal_error!(
|
||||
"A ParensAround did not get removed during operator desugaring somehow: {:#?}",
|
||||
bad_expr
|
||||
);
|
||||
}
|
||||
bad_expr @ ast::Expr::SpaceBefore(_, _) => {
|
||||
panic!(
|
||||
internal_error!(
|
||||
"A SpaceBefore did not get removed during operator desugaring somehow: {:#?}",
|
||||
bad_expr
|
||||
);
|
||||
}
|
||||
bad_expr @ ast::Expr::SpaceAfter(_, _) => {
|
||||
panic!(
|
||||
internal_error!(
|
||||
"A SpaceAfter did not get removed during operator desugaring somehow: {:#?}",
|
||||
bad_expr
|
||||
);
|
||||
}
|
||||
bad_expr @ ast::Expr::BinOps { .. } => {
|
||||
panic!(
|
||||
internal_error!(
|
||||
"A binary operator chain did not get desugared somehow: {:#?}",
|
||||
bad_expr
|
||||
);
|
||||
}
|
||||
bad_expr @ ast::Expr::UnaryOp(_, _) => {
|
||||
panic!(
|
||||
internal_error!(
|
||||
"A unary operator did not get desugared somehow: {:#?}",
|
||||
bad_expr
|
||||
);
|
||||
|
@ -1814,7 +1814,7 @@ fn canonicalize_field<'a>(
|
|||
|
||||
// A label with no value, e.g. `{ name }` (this is sugar for { name: name })
|
||||
LabelOnly(_) => {
|
||||
panic!("Somehow a LabelOnly record field was not desugared!");
|
||||
internal_error!("Somehow a LabelOnly record field was not desugared!");
|
||||
}
|
||||
|
||||
SpaceBefore(sub_field, _) | SpaceAfter(sub_field, _) => {
|
||||
|
@ -1822,7 +1822,7 @@ fn canonicalize_field<'a>(
|
|||
}
|
||||
|
||||
Malformed(_string) => {
|
||||
panic!("TODO canonicalize malformed record field");
|
||||
internal_error!("TODO canonicalize malformed record field");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -338,7 +338,7 @@ pub fn canonicalize_module_defs<'a>(
|
|||
can_exposed_imports.insert(symbol, region);
|
||||
}
|
||||
Err((_shadowed_symbol, _region)) => {
|
||||
panic!("TODO gracefully handle shadowing in imports.")
|
||||
internal_error!("TODO gracefully handle shadowing in imports.")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -359,7 +359,7 @@ pub fn canonicalize_module_defs<'a>(
|
|||
// here we do nothing special
|
||||
}
|
||||
Err((shadowed_symbol, _region)) => {
|
||||
panic!(
|
||||
internal_error!(
|
||||
"TODO gracefully handle shadowing in imports, {:?} is shadowed.",
|
||||
shadowed_symbol
|
||||
)
|
||||
|
@ -523,7 +523,7 @@ pub fn canonicalize_module_defs<'a>(
|
|||
GeneratedInfo::Builtin => {
|
||||
match crate::builtins::builtin_defs_map(*symbol, var_store) {
|
||||
None => {
|
||||
panic!("A builtin module contains a signature without implementation for {:?}", symbol)
|
||||
internal_error!("A builtin module contains a signature without implementation for {:?}", symbol)
|
||||
}
|
||||
Some(replacement_def) => {
|
||||
declarations.update_builtin_def(index, replacement_def);
|
||||
|
@ -581,7 +581,7 @@ pub fn canonicalize_module_defs<'a>(
|
|||
GeneratedInfo::Builtin => {
|
||||
match crate::builtins::builtin_defs_map(*symbol, var_store) {
|
||||
None => {
|
||||
panic!("A builtin module contains a signature without implementation for {:?}", symbol)
|
||||
internal_error!("A builtin module contains a signature without implementation for {:?}", symbol)
|
||||
}
|
||||
Some(replacement_def) => {
|
||||
declarations.update_builtin_def(index, replacement_def);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use bumpalo::collections::Vec;
|
||||
use bumpalo::Bump;
|
||||
use roc_error_macros::internal_error;
|
||||
use roc_module::called_via::BinOp::Pizza;
|
||||
use roc_module::called_via::{BinOp, CalledVia};
|
||||
use roc_module::ident::ModuleName;
|
||||
|
@ -592,7 +593,7 @@ fn binop_step<'a>(
|
|||
//
|
||||
// By design, Roc neither allows custom operators nor has any built-in operators with
|
||||
// the same precedence and different associativity, so this should never happen!
|
||||
panic!("BinOps had the same associativity, but different precedence. This should never happen!");
|
||||
internal_error!("BinOps had the same associativity, but different precedence. This should never happen!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use roc_collections::{VecMap, VecSet};
|
||||
use roc_error_macros::internal_error;
|
||||
use roc_module::ident::Ident;
|
||||
use roc_module::symbol::{IdentId, IdentIds, ModuleId, Symbol};
|
||||
use roc_problem::can::RuntimeError;
|
||||
|
@ -470,9 +471,13 @@ pub fn create_alias(
|
|||
}
|
||||
|
||||
if !hidden.is_empty() {
|
||||
panic!(
|
||||
internal_error!(
|
||||
"Found unbound type variables {:?} \n in type alias {:?} {:?} {:?} : {:?}",
|
||||
hidden, name, &vars, &infer_ext_in_output_variables, &typ
|
||||
hidden,
|
||||
name,
|
||||
&vars,
|
||||
&infer_ext_in_output_variables,
|
||||
&typ
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// use bumpalo::collections::string::String;
|
||||
// use bumpalo::collections::vec::Vec;
|
||||
use bumpalo::Bump;
|
||||
use roc_error_macros::internal_error;
|
||||
use roc_parse::ast::Expr;
|
||||
// use roc_parse::ast::{Attempting, Expr};
|
||||
// use roc_parse::ident;
|
||||
|
@ -12,7 +13,7 @@ use roc_region::all::Region;
|
|||
// use std::iter::Peekable;
|
||||
|
||||
pub fn canonical_string_literal<'a>(_arena: &Bump, _raw: &'a str, _region: Region) -> Expr<'a> {
|
||||
panic!("TODO restore canonicalization");
|
||||
internal_error!("TODO restore canonicalization");
|
||||
}
|
||||
// let mut problems = std::vec::Vec::new();
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ version.workspace = true
|
|||
roc_collections = { path = "../collections" }
|
||||
roc_module = { path = "../module" }
|
||||
roc_region = { path = "../region" }
|
||||
roc_error_macros = { path = "../../error_macros" }
|
||||
|
||||
bumpalo.workspace = true
|
||||
encode_unicode.workspace = true
|
||||
|
|
|
@ -21,6 +21,7 @@ use crate::type_annotation;
|
|||
use bumpalo::collections::Vec;
|
||||
use bumpalo::Bump;
|
||||
use roc_collections::soa::Slice;
|
||||
use roc_error_macros::internal_error;
|
||||
use roc_module::called_via::{BinOp, CalledVia, UnaryOp};
|
||||
use roc_region::all::{Loc, Position, Region};
|
||||
|
||||
|
@ -2479,10 +2480,10 @@ fn ident_to_expr<'a>(arena: &'a Bump, src: Ident<'a>) -> Expr<'a> {
|
|||
// TODO: make this state impossible to represent in Ident::Access,
|
||||
// by splitting out parts[0] into a separate field with a type of `&'a str`,
|
||||
// rather than a `&'a [Accessor<'a>]`.
|
||||
panic!("Parsed an Ident::Access with a first part of a tuple index");
|
||||
internal_error!("Parsed an Ident::Access with a first part of a tuple index");
|
||||
}
|
||||
None => {
|
||||
panic!("Parsed an Ident::Access with no parts");
|
||||
internal_error!("Parsed an Ident::Access with no parts");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue