mirror of
https://github.com/roc-lang/roc.git
synced 2025-07-24 15:03:46 +00:00
make errors more correct and check for utf8 bytes
This commit is contained in:
parent
07eb3614ea
commit
08179d2a65
2 changed files with 6 additions and 8 deletions
|
@ -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!(
|
||||
|
|
|
@ -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, _) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue