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);
|
println!("{}", &context);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if !state.errors.is_empty() {
|
if !state.errors.is_empty() {
|
||||||
// return Err(ReidError::TypeInferenceErrors(state.errors));
|
return Err(ReidError::TypeInferenceErrors(state.errors));
|
||||||
// }
|
}
|
||||||
|
|
||||||
let state = context.pass(&mut TypeCheck { refs: &refs });
|
let state = context.pass(&mut TypeCheck { refs: &refs });
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
|
@ -43,18 +43,11 @@ impl FunctionDefinition {
|
|||||||
type_refs: &TypeRefs,
|
type_refs: &TypeRefs,
|
||||||
state: &mut PassState<ErrorKind>,
|
state: &mut PassState<ErrorKind>,
|
||||||
) -> Result<(), ErrorKind> {
|
) -> Result<(), ErrorKind> {
|
||||||
|
let mut scope_hints = ScopeTypeRefs::from(type_refs);
|
||||||
for param in &self.parameters {
|
for param in &self.parameters {
|
||||||
let param_t = state.or_else(param.1.assert_known(), Vague(Unknown), self.signature());
|
let param_t = state.or_else(param.1.assert_known(), Vague(Unknown), self.signature());
|
||||||
let res = state
|
let res = scope_hints
|
||||||
.scope
|
.new_var(param.0.clone(), false, ¶m_t)
|
||||||
.variables
|
|
||||||
.set(
|
|
||||||
param.0.clone(),
|
|
||||||
ScopeVariable {
|
|
||||||
ty: param_t,
|
|
||||||
mutable: false,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.or(Err(ErrorKind::VariableAlreadyDefined(param.0.clone())));
|
.or(Err(ErrorKind::VariableAlreadyDefined(param.0.clone())));
|
||||||
state.ok(res, self.signature());
|
state.ok(res, self.signature());
|
||||||
}
|
}
|
||||||
@ -62,7 +55,6 @@ impl FunctionDefinition {
|
|||||||
match &mut self.kind {
|
match &mut self.kind {
|
||||||
FunctionDefinitionKind::Local(block, _) => {
|
FunctionDefinitionKind::Local(block, _) => {
|
||||||
state.scope.return_type_hint = Some(self.return_type.clone());
|
state.scope.return_type_hint = Some(self.return_type.clone());
|
||||||
let scope_hints = ScopeTypeRefs::from(type_refs);
|
|
||||||
|
|
||||||
// Infer block return type
|
// Infer block return type
|
||||||
let ret_res = block.infer_types(state, &scope_hints);
|
let ret_res = block.infer_types(state, &scope_hints);
|
||||||
|
Loading…
Reference in New Issue
Block a user