mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
Merge branch 'trunk' into applied_tag_functions
This commit is contained in:
commit
6e1f42f990
36 changed files with 1059 additions and 440 deletions
|
@ -424,6 +424,8 @@ impl<'a> Procs<'a> {
|
|||
is_self_recursive: bool,
|
||||
ret_var: Variable,
|
||||
) {
|
||||
let number_of_arguments = loc_args.len();
|
||||
|
||||
match patterns_to_when(env, layout_cache, loc_args, ret_var, loc_body) {
|
||||
Ok((_, pattern_symbols, body)) => {
|
||||
// a named closure. Since these aren't specialized by the surrounding
|
||||
|
@ -444,17 +446,22 @@ impl<'a> Procs<'a> {
|
|||
}
|
||||
|
||||
Err(error) => {
|
||||
// If the function has invalid patterns in its arguments,
|
||||
// its call sites will code gen to runtime errors. This happens
|
||||
// at the call site so we don't have to try to define the
|
||||
// function LLVM, which would be difficult considering LLVM
|
||||
// wants to know what symbols each argument corresponds to,
|
||||
// and in this case the patterns were invalid, so we don't know
|
||||
// what the symbols ought to be.
|
||||
let mut pattern_symbols = Vec::with_capacity_in(number_of_arguments, env.arena);
|
||||
|
||||
let error_msg = format!("TODO generate a RuntimeError message for {:?}", error);
|
||||
for _ in 0..number_of_arguments {
|
||||
pattern_symbols.push(env.unique_symbol());
|
||||
}
|
||||
|
||||
self.runtime_errors.insert(name, env.arena.alloc(error_msg));
|
||||
self.partial_procs.insert(
|
||||
name,
|
||||
PartialProc {
|
||||
annotation,
|
||||
pattern_symbols: pattern_symbols.into_bump_slice(),
|
||||
captured_symbols: CapturedSymbols::None,
|
||||
body: roc_can::expr::Expr::RuntimeError(error.value),
|
||||
is_self_recursive: false,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1788,10 +1795,11 @@ fn specialize_external<'a>(
|
|||
let snapshot = env.subs.snapshot();
|
||||
let cache_snapshot = layout_cache.snapshot();
|
||||
|
||||
let unified = roc_unify::unify::unify(env.subs, annotation, fn_var);
|
||||
let _unified = roc_unify::unify::unify(env.subs, annotation, fn_var);
|
||||
|
||||
let is_valid = matches!(unified, roc_unify::unify::Unified::Success(_));
|
||||
debug_assert!(is_valid, "unificaton failure for {:?}", proc_name);
|
||||
// This will not hold for programs with type errors
|
||||
// let is_valid = matches!(unified, roc_unify::unify::Unified::Success(_));
|
||||
// debug_assert!(is_valid, "unificaton failure for {:?}", proc_name);
|
||||
|
||||
// if this is a closure, add the closure record argument
|
||||
let pattern_symbols = if let CapturedSymbols::Captured(_) = captured_symbols {
|
||||
|
@ -2131,9 +2139,7 @@ fn build_specialized_proc_adapter<'a>(
|
|||
arg_layouts.push(layout);
|
||||
}
|
||||
|
||||
let ret_layout = layout_cache
|
||||
.from_var(&env.arena, ret_var, env.subs)
|
||||
.unwrap_or_else(|err| panic!("TODO handle invalid function {:?}", err));
|
||||
let ret_layout = layout_cache.from_var(&env.arena, ret_var, env.subs)?;
|
||||
|
||||
build_specialized_proc(
|
||||
env.arena,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue