Skip to content

Commit 4ac2862

Browse files
committed
fix: recover from invalid type errors in define_function
1 parent 218c6bf commit 4ac2862

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

compiler/src/unit.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,15 +577,27 @@ impl<'a> CompilationUnit<'a> {
577577
Some(type_) if type_ == TypeName::VOID => None,
578578
Some(type_) => {
579579
let type_ = self.try_resolve_type(&type_, scope, decl.span)?;
580-
Some(scope.get_type_index(&type_, self.pool).with_span(decl.span)?)
580+
match scope.get_type_index(&type_, self.pool) {
581+
Ok(idx) => Some(idx),
582+
Err(err) => {
583+
self.report(err.with_span(decl.span))?;
584+
None
585+
}
586+
}
581587
}
582588
};
583589

584590
let mut parameters = Vec::new();
585591

586592
for param in &spec.source.parameters {
587593
let type_ = self.try_resolve_type(&param.type_, scope, decl.span)?;
588-
let type_idx = scope.get_type_index(&type_, self.pool).with_span(decl.span)?;
594+
let type_idx = match scope.get_type_index(&type_, self.pool) {
595+
Ok(idx) => idx,
596+
Err(err) => {
597+
self.report(err.with_span(decl.span))?;
598+
continue;
599+
}
600+
};
589601
let flags = ParameterFlags::new()
590602
.with_is_optional(param.qualifiers.contain(Qualifier::Optional))
591603
.with_is_out(param.qualifiers.contain(Qualifier::Out))

0 commit comments

Comments
 (0)