mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00: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
2 changed files with 38 additions and 15 deletions
|
@ -271,10 +271,20 @@ impl<'a> Context<'a> {
|
||||||
fn get_var_info(&self, symbol: Symbol) -> VarInfo {
|
fn get_var_info(&self, symbol: Symbol) -> VarInfo {
|
||||||
match self.vars.get(&symbol) {
|
match self.vars.get(&symbol) {
|
||||||
Some(info) => *info,
|
Some(info) => *info,
|
||||||
None => panic!(
|
None => {
|
||||||
"Symbol {:?} {} has no info in {:?}",
|
eprintln!(
|
||||||
symbol, symbol, self.vars
|
"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 arg_layouts = top_level.arguments;
|
||||||
let ret_layout = top_level.result;
|
let ret_layout = top_level.result;
|
||||||
|
|
||||||
|
|
||||||
match closure_data_layout {
|
match closure_data_layout {
|
||||||
RawFunctionLayout::Function(_, lambda_set, _) => {
|
RawFunctionLayout::Function(_, lambda_set, _) => {
|
||||||
lowlevel_match_on_lambda_set(
|
lowlevel_match_on_lambda_set(
|
||||||
$env,
|
$env,
|
||||||
lambda_set,
|
lambda_set,
|
||||||
|
$op,
|
||||||
$closure_data_symbol,
|
$closure_data_symbol,
|
||||||
|top_level_function, closure_data, closure_env_layout, specialization_id| self::Call {
|
|top_level_function, closure_data, closure_env_layout, specialization_id| self::Call {
|
||||||
call_type: CallType::HigherOrderLowLevel {
|
call_type: CallType::HigherOrderLowLevel {
|
||||||
|
@ -7687,6 +7689,7 @@ pub fn num_argument_to_int_or_float(
|
||||||
fn lowlevel_match_on_lambda_set<'a, ToLowLevelCall>(
|
fn lowlevel_match_on_lambda_set<'a, ToLowLevelCall>(
|
||||||
env: &mut Env<'a, '_>,
|
env: &mut Env<'a, '_>,
|
||||||
lambda_set: LambdaSet<'a>,
|
lambda_set: LambdaSet<'a>,
|
||||||
|
op: LowLevel,
|
||||||
closure_data_symbol: Symbol,
|
closure_data_symbol: Symbol,
|
||||||
to_lowlevel_call: ToLowLevelCall,
|
to_lowlevel_call: ToLowLevelCall,
|
||||||
return_layout: Layout<'a>,
|
return_layout: Layout<'a>,
|
||||||
|
@ -7726,19 +7729,29 @@ where
|
||||||
env.arena.alloc(result),
|
env.arena.alloc(result),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Layout::Struct(_) => {
|
Layout::Struct(_) => match lambda_set.set.get(0) {
|
||||||
let function_symbol = lambda_set.set[0].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();
|
build_call(env, call, assigned, return_layout, env.arena.alloc(hole))
|
||||||
let call = to_lowlevel_call(
|
}
|
||||||
function_symbol,
|
None => {
|
||||||
closure_data_symbol,
|
eprintln!(
|
||||||
lambda_set.is_represented(),
|
"a function passed to `{:?}` LowLevel call has an empty lambda set!
|
||||||
call_spec_id,
|
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) => {
|
Layout::Builtin(Builtin::Int1) => {
|
||||||
let closure_tag_id_symbol = closure_data_symbol;
|
let closure_tag_id_symbol = closure_data_symbol;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue