DylanSp / faust-lang

An experimental language for exploring contract-based programming
MIT License
0 stars 0 forks source link

Implement typechecker #21

Open DylanSp opened 1 year ago

DylanSp commented 1 year ago

Reference https://github.com/DylanSp/faust-lang/issues/2

No type inference - all variable and function declarations must be explicitly typed.

DylanSp commented 1 year ago

If I implement the idea from https://github.com/DylanSp/faust-lang/issues/28 about parametrizing AST nodes with type info - the typechecker could, instead of returning "successfully typechecked" vs. "type error(s)", include type errors in the annotated AST:

type Type = TypeBool | TypeInt | TypeError;
interface TypeError {
  tag: "Error";
  location: ast.Location;
  message: string;
}

See https://matklad.github.io/2023/08/17/typescript-is-surprisingly-ok-for-compilers.html.