plum
git clone https://git.pyrossh.dev/plum
A statically typed, imperative programming language inspired by rust, python
a2cecd5
— Peter John
2026-11-11T00:59:48+05:30
checker: leave types with no type variable as they are when zonking
compiler/checker/src/callsites.rs
CHANGED
|
@@ -145,7 +145,13 @@ pub(crate) fn recordOpenDispatches(info: &TypedInfo) -> bool {
|
|
|
145
145
|
let binds = s.record_binds.borrow();
|
|
146
146
|
let empty = Binds::new();
|
|
147
147
|
let b = binds.as_ref().unwrap_or(&empty);
|
|
148
|
+
let mut add = |t: &PlumType| {
|
|
149
|
+
if hasTVars(t) {
|
|
148
|
-
|
|
150
|
+
appsNamed(&substVars(t, b), &wanted, &mut instances)
|
|
151
|
+
} else {
|
|
152
|
+
appsNamed(t, &wanted, &mut instances)
|
|
153
|
+
}
|
|
154
|
+
};
|
|
149
155
|
if let Some(r) = s.record.borrow().as_ref() {
|
|
150
156
|
r.values().for_each(&mut add);
|
|
151
157
|
}
|
compiler/checker/src/program.rs
CHANGED
|
@@ -207,7 +207,9 @@ pub(crate) fn checkSourceOnce(source: &ast::Source) -> (CheckResult<()>, TypedIn
|
|
|
207
207
|
.chain(info.inst_expr_types.values_mut())
|
|
208
208
|
.chain(info.inst_annotated.values_mut())
|
|
209
209
|
{
|
|
210
|
+
if hasTVars(t) {
|
|
210
|
-
|
|
211
|
+
*t = defaultVars(&substVars(t, &binds));
|
|
212
|
+
}
|
|
211
213
|
}
|
|
212
214
|
for ((id, annotated), t) in recorded {
|
|
213
215
|
if annotated {
|
compiler/checker/src/unification.rs
CHANGED
|
@@ -51,6 +51,18 @@ pub(crate) fn substVars(ty: &PlumType, b: &Binds) -> PlumType {
|
|
|
51
51
|
go(ty, b, 0)
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/// Whether `ty` mentions any type variable: `substVars` and `defaultVars` leave a type with
|
|
55
|
+
/// none as it is, so a caller can skip rebuilding it.
|
|
56
|
+
pub(crate) fn hasTVars(ty: &PlumType) -> bool {
|
|
57
|
+
use PlumType::*;
|
|
58
|
+
match ty {
|
|
59
|
+
TVar(_) => true,
|
|
60
|
+
TApp(_, args) => args.iter().any(hasTVars),
|
|
61
|
+
TFun(ps, r) => ps.iter().any(hasTVars) || hasTVars(r),
|
|
62
|
+
_ => false,
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
54
66
|
/// Replaces every remaining unresolved inference variable (`_`, `_tN`,
|
|
55
67
|
/// `_closure_x`) by `Unit`.
|
|
56
68
|
pub(crate) fn defaultVars(ty: &PlumType) -> PlumType {
|