Fix issue in type-inference pass about function params not registering
This commit is contained in:
parent
5acd1624fd
commit
1e759d49c7
@ -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)]
|
||||
|
@ -43,18 +43,11 @@ impl FunctionDefinition {
|
||||
type_refs: &TypeRefs,
|
||||
state: &mut PassState<ErrorKind>,
|
||||
) -> 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);
|
||||
|
Loading…
Reference in New Issue
Block a user