Skip to content

Commit

Permalink
Clean up ICE error reporting a touch
Browse files Browse the repository at this point in the history
  • Loading branch information
cgswords committed May 28, 2024
1 parent e33d519 commit 10a9b57
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
5 changes: 3 additions & 2 deletions external-crates/move/crates/move-compiler/src/typing/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ impl<'env> Context<'env> {
self.use_funs.last().unwrap().color.unwrap()
}

pub fn reset_for_module_item(&mut self) {
pub fn reset_for_module_item(&mut self, loc: Loc) {
self.named_block_map = BTreeMap::new();
self.return_type = None;
self.locals = UniqueMap::new();
Expand All @@ -497,7 +497,8 @@ impl<'env> Context<'env> {
self.lambda_expansion = vec![];

if !self.ide_info.is_empty() {
eprintln!("IDE info should be cleared after each item");
self.env
.add_diag(ice!((loc, "IDE info should be cleared after each item")));
self.ide_info = IDEInfo::new();
}
}
Expand Down
20 changes: 11 additions & 9 deletions external-crates/move/crates/move-compiler/src/typing/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ fn module(
context.add_use_funs_scope(use_funs);
structs
.iter_mut()
.for_each(|(_, _, s)| struct_def(context, s));
.for_each(|(loc, _name, s)| struct_def(context, loc, s));
enums.iter_mut().for_each(|(_, _, e)| enum_def(context, e));
process_attributes(context, &attributes);
let constants = nconstants.map(|name, c| constant(context, name, c));
Expand Down Expand Up @@ -268,7 +268,7 @@ fn function(context: &mut Context, name: FunctionName, f: N::Function) -> T::Fun
} = f;
context.env.add_warning_filter_scope(warning_filter.clone());
assert!(context.constraints.is_empty());
context.reset_for_module_item();
context.reset_for_module_item(name.loc());
context.current_function = Some(name);
context.in_macro_function = macro_.is_some();
process_attributes(context, &attributes);
Expand Down Expand Up @@ -358,9 +358,9 @@ fn function_body(context: &mut Context, sp!(loc, nb_): N::FunctionBody) -> T::Fu
// Constants
//**************************************************************************************************

fn constant(context: &mut Context, _name: ConstantName, nconstant: N::Constant) -> T::Constant {
fn constant(context: &mut Context, name: ConstantName, nconstant: N::Constant) -> T::Constant {
assert!(context.constraints.is_empty());
context.reset_for_module_item();
context.reset_for_module_item(name.loc());

let N::Constant {
warning_filter,
Expand Down Expand Up @@ -675,9 +675,9 @@ mod check_valid_constant {
// Data Types
//**************************************************************************************************

fn struct_def(context: &mut Context, s: &mut N::StructDefinition) {
fn struct_def(context: &mut Context, sloc: Loc, s: &mut N::StructDefinition) {
assert!(context.constraints.is_empty());
context.reset_for_module_item();
context.reset_for_module_item(sloc);
context
.env
.add_warning_filter_scope(s.warning_filter.clone());
Expand Down Expand Up @@ -737,8 +737,9 @@ fn enum_def(context: &mut Context, enum_: &mut N::EnumDefinition) {
let enum_type_params = &enum_.type_parameters;

let mut field_types = vec![];
for (_, _, variant) in enum_.variants.iter_mut() {
let mut varient_fields = variant_def(context, enum_abilities, enum_type_params, variant);
for (vloc, _, variant) in enum_.variants.iter_mut() {
let mut varient_fields =
variant_def(context, vloc, enum_abilities, enum_type_params, variant);
field_types.append(&mut varient_fields);
}

Expand All @@ -748,11 +749,12 @@ fn enum_def(context: &mut Context, enum_: &mut N::EnumDefinition) {

fn variant_def(
context: &mut Context,
vloc: Loc,
enum_abilities: &AbilitySet,
enum_tparams: &[DatatypeTypeParameter],
v: &mut N::VariantDefinition,
) -> Vec<(usize, Type)> {
context.reset_for_module_item();
context.reset_for_module_item(vloc);

let field_map = match &mut v.fields {
N::VariantFields::Empty => return vec![],
Expand Down

0 comments on commit 10a9b57

Please sign in to comment.