mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-13 09:49:11 +03:00
Merge pull request #1601 from rtfeldman/panic-lookup-not-in-scope
Delay panicking on LookupNotInScope until the error is reported
This commit is contained in:
commit
ce9f85ecbc
@ -271,10 +271,20 @@ impl<'a> Context<'a> {
|
||||
fn get_var_info(&self, symbol: Symbol) -> VarInfo {
|
||||
match self.vars.get(&symbol) {
|
||||
Some(info) => *info,
|
||||
None => panic!(
|
||||
"Symbol {:?} {} has no info in {:?}",
|
||||
symbol, symbol, self.vars
|
||||
),
|
||||
None => {
|
||||
eprintln!(
|
||||
"Symbol {:?} {} has no info in self.vars",
|
||||
symbol,
|
||||
symbol, // self.vars
|
||||
);
|
||||
|
||||
VarInfo {
|
||||
persistent: true,
|
||||
reference: false,
|
||||
consume: false,
|
||||
reset: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2682,11 +2682,13 @@ macro_rules! match_on_closure_argument {
|
||||
let arg_layouts = top_level.arguments;
|
||||
let ret_layout = top_level.result;
|
||||
|
||||
|
||||
match closure_data_layout {
|
||||
RawFunctionLayout::Function(_, lambda_set, _) => {
|
||||
lowlevel_match_on_lambda_set(
|
||||
$env,
|
||||
lambda_set,
|
||||
$op,
|
||||
$closure_data_symbol,
|
||||
|top_level_function, closure_data, closure_env_layout, specialization_id| self::Call {
|
||||
call_type: CallType::HigherOrderLowLevel {
|
||||
@ -7687,6 +7689,7 @@ pub fn num_argument_to_int_or_float(
|
||||
fn lowlevel_match_on_lambda_set<'a, ToLowLevelCall>(
|
||||
env: &mut Env<'a, '_>,
|
||||
lambda_set: LambdaSet<'a>,
|
||||
op: LowLevel,
|
||||
closure_data_symbol: Symbol,
|
||||
to_lowlevel_call: ToLowLevelCall,
|
||||
return_layout: Layout<'a>,
|
||||
@ -7726,19 +7729,29 @@ where
|
||||
env.arena.alloc(result),
|
||||
)
|
||||
}
|
||||
Layout::Struct(_) => {
|
||||
let function_symbol = lambda_set.set[0].0;
|
||||
Layout::Struct(_) => match lambda_set.set.get(0) {
|
||||
Some((function_symbol, _)) => {
|
||||
let call_spec_id = env.next_call_specialization_id();
|
||||
let call = to_lowlevel_call(
|
||||
*function_symbol,
|
||||
closure_data_symbol,
|
||||
lambda_set.is_represented(),
|
||||
call_spec_id,
|
||||
);
|
||||
|
||||
let call_spec_id = env.next_call_specialization_id();
|
||||
let call = to_lowlevel_call(
|
||||
function_symbol,
|
||||
closure_data_symbol,
|
||||
lambda_set.is_represented(),
|
||||
call_spec_id,
|
||||
);
|
||||
build_call(env, call, assigned, return_layout, env.arena.alloc(hole))
|
||||
}
|
||||
None => {
|
||||
eprintln!(
|
||||
"a function passed to `{:?}` LowLevel call has an empty lambda set!
|
||||
The most likely reason is that some symbol you use is not in scope.
|
||||
",
|
||||
op
|
||||
);
|
||||
|
||||
build_call(env, call, assigned, return_layout, env.arena.alloc(hole))
|
||||
}
|
||||
hole.clone()
|
||||
}
|
||||
},
|
||||
Layout::Builtin(Builtin::Int1) => {
|
||||
let closure_tag_id_symbol = closure_data_symbol;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user