mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-13 15:26:24 +00:00
Merge remote-tracking branch 'origin/main' into Frame-Limited
This commit is contained in:
commit
a3cea59bb6
63 changed files with 3552 additions and 846 deletions
|
@ -4125,6 +4125,41 @@ pub fn with_hole<'a>(
|
|||
hole,
|
||||
),
|
||||
|
||||
IngestedFile(_, bytes, var) => {
|
||||
let interned = layout_cache.from_var(env.arena, var, env.subs).unwrap();
|
||||
let layout = layout_cache.get_in(interned);
|
||||
|
||||
match layout {
|
||||
Layout::Builtin(Builtin::List(elem_layout)) if elem_layout == Layout::U8 => {
|
||||
let mut elements = Vec::with_capacity_in(bytes.len(), env.arena);
|
||||
for byte in bytes.iter() {
|
||||
elements.push(ListLiteralElement::Literal(Literal::Byte(*byte)));
|
||||
}
|
||||
let expr = Expr::Array {
|
||||
elem_layout,
|
||||
elems: elements.into_bump_slice(),
|
||||
};
|
||||
|
||||
Stmt::Let(assigned, expr, interned, hole)
|
||||
}
|
||||
Layout::Builtin(Builtin::Str) => Stmt::Let(
|
||||
assigned,
|
||||
Expr::Literal(Literal::Str(
|
||||
// This is safe because we ensure the utf8 bytes are valid earlier in the compiler pipeline.
|
||||
arena.alloc(
|
||||
unsafe { std::str::from_utf8_unchecked(bytes.as_ref()) }.to_owned(),
|
||||
),
|
||||
)),
|
||||
Layout::STR,
|
||||
hole,
|
||||
),
|
||||
_ => {
|
||||
// This will not manifest as a real runtime error and is just returned to have a value here.
|
||||
// The actual type error during solve will be fatal.
|
||||
runtime_error(env, "Invalid type for ingested file")
|
||||
}
|
||||
}
|
||||
}
|
||||
SingleQuote(_, _, character, _) => {
|
||||
let layout = layout_cache
|
||||
.from_var(env.arena, variable, env.subs)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue