Type checking unannotated expressions
This commit is contained in:
parent
de83eb6fcd
commit
a4daf88085
2 changed files with 9 additions and 4 deletions
|
|
@ -340,10 +340,15 @@ export function typecheck(defs: Definition[], typeDefs: TypeDefinition[] = []) {
|
|||
|
||||
// Check each annotated def
|
||||
for (const def of defs) {
|
||||
if (def.annotation && def.body) {
|
||||
if (def.body) {
|
||||
const subst: Subst = new Map();
|
||||
const err = check(def.body, def.annotation.type, env, subst);
|
||||
if (err) warn(err, def.body);
|
||||
if (def.annotation) {
|
||||
const err = check(def.body, def.annotation.type, env, subst);
|
||||
if (err) warn(err, def.body);
|
||||
} else {
|
||||
const t = infer(def.body, env, subst);
|
||||
if (t) env.set(def.name, t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue