fix first compiler pass of errors
This commit is contained in:
parent
a12c374258
commit
9f96e4bc5a
|
@ -2491,7 +2491,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
|
|
||||||
let mut previous_defined_names = vec![];
|
let mut previous_defined_names = vec![];
|
||||||
let mut names_to_define = vec![];
|
let mut names_to_define = vec![];
|
||||||
name_index_assigns.iter().for_each(|(name, index, _)| {
|
name_index_assigns.iter().for_each(|(name, index)| {
|
||||||
if let Some((index, prev_name)) = defined_indices
|
if let Some((index, prev_name)) = defined_indices
|
||||||
.iter()
|
.iter()
|
||||||
.find(|(defined_index, _nm)| defined_index == index)
|
.find(|(defined_index, _nm)| defined_index == index)
|
||||||
|
@ -2505,20 +2505,16 @@ impl<'a> CodeGenerator<'a> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let tuple_name_assigns = previous_defined_names
|
let tuple_name_assigns = previous_defined_names.into_iter().rev().fold(
|
||||||
.into_iter()
|
next_then,
|
||||||
.map(|(index, prev_name, name)| {
|
|inner_then, (index, prev_name, name)| {
|
||||||
AirTree::let_assignment(
|
AirTree::let_assignment(
|
||||||
name,
|
name,
|
||||||
AirTree::local_var(prev_name, items_type[index].clone()),
|
AirTree::local_var(prev_name, items_type[index].clone()),
|
||||||
|
inner_then,
|
||||||
)
|
)
|
||||||
})
|
},
|
||||||
.collect_vec();
|
);
|
||||||
|
|
||||||
let mut tuple_item_assigns = name_index_assigns
|
|
||||||
.into_iter()
|
|
||||||
.map(|(_, _, item)| item)
|
|
||||||
.collect_vec();
|
|
||||||
|
|
||||||
match props {
|
match props {
|
||||||
ClauseProperties {
|
ClauseProperties {
|
||||||
|
@ -2533,10 +2529,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut sequence = tuple_name_assigns;
|
let tuple_name_assigns = if props.final_clause && !names_to_define.is_empty() {
|
||||||
sequence.append(&mut tuple_item_assigns);
|
|
||||||
|
|
||||||
if props.final_clause && !names_to_define.is_empty() {
|
|
||||||
names_to_define.sort_by(|(id1, _), (id2, _)| id1.cmp(id2));
|
names_to_define.sort_by(|(id1, _), (id2, _)| id1.cmp(id2));
|
||||||
|
|
||||||
let names =
|
let names =
|
||||||
|
@ -2550,18 +2543,19 @@ impl<'a> CodeGenerator<'a> {
|
||||||
names
|
names
|
||||||
});
|
});
|
||||||
|
|
||||||
sequence.insert(
|
AirTree::tuple_access(
|
||||||
0,
|
names,
|
||||||
AirTree::tuple_access(
|
subject_tipo.clone(),
|
||||||
names,
|
AirTree::local_var(&props.original_subject_name, subject_tipo.clone()),
|
||||||
subject_tipo.clone(),
|
None,
|
||||||
AirTree::local_var(&props.original_subject_name, subject_tipo.clone()),
|
false,
|
||||||
None,
|
)
|
||||||
false,
|
.hoist_over(tuple_name_assigns)
|
||||||
),
|
} else {
|
||||||
);
|
tuple_name_assigns
|
||||||
}
|
};
|
||||||
(AirTree::void(), AirTree::UnhoistedSequence(sequence))
|
|
||||||
|
(AirTree::void(), tuple_name_assigns)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2745,81 +2739,77 @@ impl<'a> CodeGenerator<'a> {
|
||||||
src_code: &str,
|
src_code: &str,
|
||||||
lines: &LineNumbers,
|
lines: &LineNumbers,
|
||||||
) -> AirTree {
|
) -> AirTree {
|
||||||
let checked_args = arguments
|
let mut arg_names = vec![];
|
||||||
.iter()
|
|
||||||
.enumerate()
|
|
||||||
.map(|(index, arg)| {
|
|
||||||
let arg_name = arg
|
|
||||||
.arg_name
|
|
||||||
.get_variable_name()
|
|
||||||
.map(|arg| arg.to_string())
|
|
||||||
.unwrap_or_else(|| format!("__arg_{}", index));
|
|
||||||
let arg_span = arg.location;
|
|
||||||
|
|
||||||
if !(has_context && index == arguments.len() - 1) {
|
let checked_args =
|
||||||
let param = AirTree::local_var(&arg_name, data());
|
arguments
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
.rev()
|
||||||
|
.fold(body, |inner_then, (index, arg)| {
|
||||||
|
let arg_name = arg.arg_name.get_variable_name().unwrap_or("_").to_string();
|
||||||
|
let arg_span = arg.location;
|
||||||
|
|
||||||
let actual_type = convert_opaque_type(&arg.tipo, &self.data_types);
|
arg_names.push(arg_name.clone());
|
||||||
|
|
||||||
let msg_func = match self.tracing {
|
if !(has_context && index == arguments.len() - 1) && &arg_name != "_" {
|
||||||
TraceLevel::Silent => None,
|
let param = AirTree::local_var(&arg_name, data());
|
||||||
TraceLevel::Compact | TraceLevel::Verbose => {
|
|
||||||
let msg = match self.tracing {
|
|
||||||
TraceLevel::Silent => unreachable!("excluded from pattern guards"),
|
|
||||||
TraceLevel::Compact => lines
|
|
||||||
.line_and_column_number(arg_span.start)
|
|
||||||
.expect("Out of bounds span")
|
|
||||||
.to_string(),
|
|
||||||
TraceLevel::Verbose => src_code
|
|
||||||
.get(arg_span.start..arg_span.end)
|
|
||||||
.expect("Out of bounds span")
|
|
||||||
.to_string(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let msg_func_name = msg.split_whitespace().join("");
|
let actual_type = convert_opaque_type(&arg.tipo, &self.data_types);
|
||||||
|
|
||||||
self.special_functions.insert_new_function(
|
let msg_func = match self.tracing {
|
||||||
msg_func_name.to_string(),
|
TraceLevel::Silent => None,
|
||||||
Term::string(msg),
|
TraceLevel::Compact | TraceLevel::Verbose => {
|
||||||
string(),
|
let msg = match self.tracing {
|
||||||
);
|
TraceLevel::Silent => {
|
||||||
|
unreachable!("excluded from pattern guards")
|
||||||
|
}
|
||||||
|
TraceLevel::Compact => lines
|
||||||
|
.line_and_column_number(arg_span.start)
|
||||||
|
.expect("Out of bounds span")
|
||||||
|
.to_string(),
|
||||||
|
TraceLevel::Verbose => src_code
|
||||||
|
.get(arg_span.start..arg_span.end)
|
||||||
|
.expect("Out of bounds span")
|
||||||
|
.to_string(),
|
||||||
|
};
|
||||||
|
|
||||||
Some(self.special_functions.use_function_msg(msg_func_name))
|
let msg_func_name = msg.split_whitespace().join("");
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let assign = self.assignment(
|
self.special_functions.insert_new_function(
|
||||||
&Pattern::Var {
|
msg_func_name.to_string(),
|
||||||
location: Span::empty(),
|
Term::string(msg),
|
||||||
name: arg_name.to_string(),
|
string(),
|
||||||
},
|
);
|
||||||
param,
|
|
||||||
&actual_type,
|
|
||||||
AssignmentProperties {
|
|
||||||
value_type: data(),
|
|
||||||
kind: AssignmentKind::Expect,
|
|
||||||
remove_unused: false,
|
|
||||||
full_check: true,
|
|
||||||
msg_func,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
(arg_name, assign)
|
Some(self.special_functions.use_function_msg(msg_func_name))
|
||||||
} else {
|
}
|
||||||
(arg_name, AirTree::no_op())
|
};
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect_vec();
|
|
||||||
|
|
||||||
let arg_names = checked_args
|
self.assignment(
|
||||||
.iter()
|
&Pattern::Var {
|
||||||
.map(|(name, _)| name.to_string())
|
location: Span::empty(),
|
||||||
.collect_vec();
|
name: arg_name.to_string(),
|
||||||
|
},
|
||||||
|
param,
|
||||||
|
inner_then,
|
||||||
|
&actual_type,
|
||||||
|
AssignmentProperties {
|
||||||
|
value_type: data(),
|
||||||
|
kind: AssignmentKind::Expect,
|
||||||
|
remove_unused: false,
|
||||||
|
full_check: true,
|
||||||
|
msg_func,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
inner_then
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let arg_assigns =
|
arg_names.reverse();
|
||||||
AirTree::UnhoistedSequence(checked_args.into_iter().map(|(_, arg)| arg).collect_vec());
|
|
||||||
|
|
||||||
AirTree::anon_func(arg_names, arg_assigns.hoist_over(body))
|
AirTree::anon_func(arg_names, checked_args)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hoist_functions_to_validator(
|
fn hoist_functions_to_validator(
|
||||||
|
|
Loading…
Reference in New Issue