Basic type checker #6
Reference in New Issue
Block a user
Delete Branch "feat/basic-type-checker"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR implements a basic type checker. It handles simple python constructs such as:
+,-,*,/, etc.)>,<,>=,<=, etc.)and,or)ifstatementscast(Type, expression))Some types and operations are defined by default to match what Python provides (e.g. literal types and their operations). The checker also supports importing custom type definitions from Midas files.
Currently, type checking is strict: types must match exactly. This is especially true for function return types, which must all be the same in a given function, and ternary expressions, whose branches must be of the same type.
Subtyping and genericity will be added in a separate PR
The type checker generates a list of diagnostics (errors, warnings and infos), which can be highlighted in the source file using the following command: