mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
commit
58fad36f9d
62 changed files with 1247 additions and 455 deletions
|
@ -1086,7 +1086,36 @@ pub fn can_problem<'b>(
|
|||
} else {
|
||||
"TOO FEW TYPE ARGUMENTS".to_string()
|
||||
};
|
||||
|
||||
severity = Severity::RuntimeError;
|
||||
}
|
||||
Problem::UnappliedCrash { region } => {
|
||||
doc = alloc.stack([
|
||||
alloc.concat([
|
||||
alloc.reflow("This "), alloc.keyword("crash"), alloc.reflow(" doesn't have a message given to it:")
|
||||
]),
|
||||
alloc.region(lines.convert_region(region)),
|
||||
alloc.concat([
|
||||
alloc.keyword("crash"), alloc.reflow(" must be passed a message to crash with at the exact place it's used. "),
|
||||
alloc.keyword("crash"), alloc.reflow(" can't be used as a value that's passed around, like functions can be - it must be applied immediately!"),
|
||||
])
|
||||
]);
|
||||
title = "UNAPPLIED CRASH".to_string();
|
||||
severity = Severity::RuntimeError;
|
||||
}
|
||||
Problem::OverAppliedCrash { region } => {
|
||||
doc = alloc.stack([
|
||||
alloc.concat([
|
||||
alloc.reflow("This "),
|
||||
alloc.keyword("crash"),
|
||||
alloc.reflow(" has too many values given to it:"),
|
||||
]),
|
||||
alloc.region(lines.convert_region(region)),
|
||||
alloc.concat([
|
||||
alloc.keyword("crash"),
|
||||
alloc.reflow(" must be given exacly one message to crash with."),
|
||||
]),
|
||||
]);
|
||||
title = "OVERAPPLIED CRASH".to_string();
|
||||
severity = Severity::RuntimeError;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1375,6 +1375,42 @@ fn to_expr_report<'b>(
|
|||
}
|
||||
}
|
||||
|
||||
Reason::CrashArg => {
|
||||
let this_is = alloc.reflow("The value is");
|
||||
|
||||
let wanted = alloc.concat([
|
||||
alloc.reflow("But I can only "),
|
||||
alloc.keyword("crash"),
|
||||
alloc.reflow(" with messages of type"),
|
||||
]);
|
||||
|
||||
let details = None;
|
||||
|
||||
let lines = [
|
||||
alloc
|
||||
.reflow("This value passed to ")
|
||||
.append(alloc.keyword("crash"))
|
||||
.append(alloc.reflow(" is not a string:")),
|
||||
alloc.region(lines.convert_region(region)),
|
||||
type_comparison(
|
||||
alloc,
|
||||
found,
|
||||
expected_type,
|
||||
ExpectationContext::WhenCondition,
|
||||
add_category(alloc, this_is, &category),
|
||||
wanted,
|
||||
details,
|
||||
),
|
||||
];
|
||||
|
||||
Report {
|
||||
filename,
|
||||
title: "TYPE MISMATCH".to_string(),
|
||||
doc: alloc.stack(lines),
|
||||
severity: Severity::RuntimeError,
|
||||
}
|
||||
}
|
||||
|
||||
Reason::LowLevelOpArg { op, arg_index } => {
|
||||
panic!(
|
||||
"Compiler bug: argument #{} to low-level operation {:?} was the wrong type!",
|
||||
|
@ -1680,6 +1716,10 @@ fn format_category<'b>(
|
|||
alloc.concat([this_is, alloc.text(" an uniqueness attribute")]),
|
||||
alloc.text(" of type:"),
|
||||
),
|
||||
Crash => {
|
||||
internal_error!("calls to crash should be unconditionally admitted in any context, unexpected reachability!");
|
||||
}
|
||||
|
||||
Storage(..) | Unknown => (
|
||||
alloc.concat([this_is, alloc.text(" a value")]),
|
||||
alloc.text(" of type:"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue