make errors more correct and check for utf8 bytes

This commit is contained in:
Brendan Hansknecht 2023-04-04 17:45:23 -07:00
parent 07eb3614ea
commit 08179d2a65
No known key found for this signature in database
GPG key ID: 0EA784685083E75B
2 changed files with 6 additions and 8 deletions

View file

@ -375,14 +375,15 @@ pub fn constrain_expr(
let expected_index = expected;
constraints.equal_types(str_index, expected_index, Category::Str, region)
}
IngestedFile(_, anno) => match &anno.typ {
IngestedFile(bytes, anno) => match &anno.typ {
Type::Apply(Symbol::STR_STR, _, _) => {
if let Err(_) = std::str::from_utf8(bytes) {
todo!("cause an error for the type being wrong due to not being a utf8 string");
}
let str_index = constraints.push_type(types, Types::STR);
let expected_index = expected;
constraints.equal_types(str_index, expected_index, Category::Str, region)
// TODO: I believe we also should check to make sure they bytes are valid utf8 and bubble up an error.
// I am just not sure how the error would get bubbled up.
}
Type::Apply(Symbol::LIST_LIST, elem_type, _)
if matches!(

View file

@ -4195,10 +4195,7 @@ pub fn with_hole<'a>(
Stmt::Let(assigned, expr, list_layout, hole)
}
x => todo!(
"Unsupported requested type for ingested file, give proper error: {:?}",
x
),
_ => unreachable!("All of these cases should be dealt with earlier in the compiler, generating proper errors"),
},
SingleQuote(_, _, character, _) => {