Skip to content

Commit 1bee857

Browse files
committed
Fix abstract-errored modules not getting inference info
1 parent 2bbd3fd commit 1bee857

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

src/compiler_top.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@ impl Linker {
257257
}
258258
self.checkpoint(&global_ids, AFTER_TYPE_CHECK_CP);
259259

260+
for (_, md) in &self.modules {
261+
md.assert_valid();
262+
}
263+
260264
if config.early_exit == EarlyExitUpTo::AbstractTypecheck {
261265
return;
262266
}

src/flattening/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,15 @@ impl Module {
9090
);
9191
(port_id, direction)
9292
}
93+
94+
pub fn assert_valid(&self) {
95+
assert_eq!(
96+
self.link_info.parameters.len(),
97+
self.inference_info.parameter_inference_candidates.len(),
98+
"{}",
99+
self.link_info.name
100+
);
101+
}
93102
}
94103

95104
/// Represents an opaque type in the compiler, like `int` or `bool`.

src/flattening/typecheck/mod.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,16 @@ pub fn typecheck(pass: &mut LinkerPass, errors: &ErrorCollector) {
140140
}
141141

142142
// Skip printing not fully figured out types of there are type errors to reduce visual overhead.
143-
if errors.did_error() {
144-
return;
145-
}
146-
for (typ, span) in finalize_ctx.substitution_failures {
147-
errors.error(
148-
span,
149-
format!(
150-
"Could not fully figure out the type of this object. {}",
151-
typ.display(globals.globals, link_info)
152-
),
153-
);
143+
if !errors.did_error() {
144+
for (typ, span) in finalize_ctx.substitution_failures {
145+
errors.error(
146+
span,
147+
format!(
148+
"Could not fully figure out the type of this object. {}",
149+
typ.display(globals.globals, link_info)
150+
),
151+
);
152+
}
154153
}
155154

156155
if let GlobalObj::Module(md) = pass.get_mut() {

0 commit comments

Comments
 (0)