diff --git a/reid/src/lib.rs b/reid/src/lib.rs index a10ff79..e80bcc4 100644 --- a/reid/src/lib.rs +++ b/reid/src/lib.rs @@ -122,9 +122,9 @@ pub fn perform_all_passes(context: &mut mir::Context) -> Result<(), ReidError> { println!("{}", &context); } - // if !state.errors.is_empty() { - // return Err(ReidError::TypeInferenceErrors(state.errors)); - // } + if !state.errors.is_empty() { + return Err(ReidError::TypeInferenceErrors(state.errors)); + } let state = context.pass(&mut TypeCheck { refs: &refs }); #[cfg(debug_assertions)] diff --git a/reid/src/mir/typeinference.rs b/reid/src/mir/typeinference.rs index 31c0d5d..03f7968 100644 --- a/reid/src/mir/typeinference.rs +++ b/reid/src/mir/typeinference.rs @@ -43,18 +43,11 @@ impl FunctionDefinition { type_refs: &TypeRefs, state: &mut PassState, ) -> Result<(), ErrorKind> { + let mut scope_hints = ScopeTypeRefs::from(type_refs); for param in &self.parameters { let param_t = state.or_else(param.1.assert_known(), Vague(Unknown), self.signature()); - let res = state - .scope - .variables - .set( - param.0.clone(), - ScopeVariable { - ty: param_t, - mutable: false, - }, - ) + let res = scope_hints + .new_var(param.0.clone(), false, ¶m_t) .or(Err(ErrorKind::VariableAlreadyDefined(param.0.clone()))); state.ok(res, self.signature()); } @@ -62,7 +55,6 @@ impl FunctionDefinition { match &mut self.kind { FunctionDefinitionKind::Local(block, _) => { state.scope.return_type_hint = Some(self.return_type.clone()); - let scope_hints = ScopeTypeRefs::from(type_refs); // Infer block return type let ret_res = block.infer_types(state, &scope_hints);