Constrain string interpolation

This commit is contained in:
Richard Feldman 2020-08-29 21:37:46 -04:00
parent 5080a7e24b
commit 274e7e786d
11 changed files with 150 additions and 180 deletions

View file

@ -262,6 +262,12 @@ pub fn can_problem<'b>(
alloc.reflow(" can occur in this position."),
]),
]),
Problem::InvalidInterpolation(region) => {
todo!(
"TODO report an invalid string interpolation at region {:?}",
region
);
}
Problem::RuntimeError(runtime_error) => pretty_runtime_error(alloc, runtime_error),
};
@ -524,6 +530,12 @@ fn pretty_runtime_error<'b>(
alloc.region(region),
alloc.reflow("Only variables can be updated with record update syntax."),
]),
RuntimeError::InvalidInterpolation(region) => {
todo!(
"TODO runtime error for an invalid string interpolation at region {:?}",
region
);
}
RuntimeError::NoImplementation => todo!("no implementation, unreachable"),
RuntimeError::NonExhaustivePattern => {
unreachable!("not currently reported (but can blow up at runtime)")

View file

@ -781,7 +781,7 @@ fn to_expr_report<'b>(
unreachable!("I don't think these can be reached")
}
Reason::InterpolatedStringVar => {
Reason::StrInterpolation => {
unimplemented!("string interpolation is not implemented yet")
}
@ -875,6 +875,10 @@ fn add_category<'b>(
Int => alloc.concat(vec![this_is, alloc.text(" an integer of type:")]),
Float => alloc.concat(vec![this_is, alloc.text(" a float of type:")]),
Str => alloc.concat(vec![this_is, alloc.text(" a string of type:")]),
StrInterpolation => alloc.concat(vec![
this_is,
alloc.text(" a value in a string interpolation, which was of type:"),
]),
Lambda => alloc.concat(vec![this_is, alloc.text(" an anonymous function of type:")]),