-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement corset type checker (#431)
* Add Tests for Typing This adds a small number of valid and invalid tests for checking typing. * Distinguish loobean / boolean semantics Whilst this is a fairly esoteric part of the corset language, it is nevertheless necessary to implement in order to faithly recreate the language's semantics. * Support primitive type inference This puts in place a fairly primitive form of type inference, which doesn't really do anything at this time. However, most of the machinery is now in place... * Enable Resolution of If This puts in place the ability to resolve an if as either an if-zero or an if-notzero depending on whether the condition is loobean or boolean. In the case that it is neither, then an error is reported. At this stage, however, the mechanism for infering the type of an arbitrary expression remains somewhat limited. * Enable checking guards are boolean This adds support for checking that guards have boolean semantics. For now, checking constraints have loobean semantics is implemented but not enabled. The problem is that it breaks a lot of the existing tests! * Fix (now broken) tests This fixes a number of tests which have been broken as a result of the introduced type checking process. The biggest issue here is that we really need the ability to put return types on functions in order to resolve some situations. * Support Function Return Types This adds support for function return types, and updates a larger number of tests to use "vanishes!" to meet the loobean requirements for a constraint. This also relaxes the rules for combining types for addition and subtraction, following what corset does. In addition, this introduces a very minimal standard library which (at this time) includes only the "vanishes" declaration. * Rework Memory Example This reworks the memory example so that it now: (a) compiles; (b) makes use of the stdlib (what there is of it) to improve the overall look. There is an outstanding issue related to the return types of functions. Specifically, it seems that corset infers the return type when it is not specified. * Implement type inference This puts in place a naive algorithm for type inference of function invocations. Its somewhat awkward, but it reflects the original corset language. * Support type inference through invocations The corset language supports an interesting notion of type inference in the case that a function is declared without an explicit return type being given. Specifically, it types it polymorphically at the call site based on the types of the given arguments. * Fix Declaration Finalisation This fixes some problems with the existing finalisation algorithm. Firstly, it was sometimes finalising things more than once (which is wasteful). Secondly, it was not finalising at a fine-enough granularity (which caused problems for constant definitions which referred to themself). Finally, there were still some gremlins related to binding. * Fixes for Quick Tests This puts through various minor fixes for the quick tests. What remains now is to update the larger tests. At this stage, performance may be starting to become an issue. * Update standard library This pulls over as much of the original corset standard library as possible at the moment (which is actually most of it). There are a couple of outstanding issues to be resolved around overloading, etc. * Update Slow Tests This updates the slow test to be almost exactly as they were original defined (i.e. using the full corset syntax). At this stage, there are a number of outstanding issues which remain, and some of the tests have parts commented out.
- Loading branch information
1 parent
5b8dbce
commit f716a48
Showing
171 changed files
with
3,419 additions
and
837 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.