leo
leo copied to clipboard
Validation for Nested Function Calls and Data Types
This PR adds additional functionality and validation for function calls. Specifically, it:
- introduces the
@inline
annotation. - checks for cycles in the call graph (recursion is not allowed).
- refactors
SymbolTable
intopasses/common
- checks that functions are called appropriately
- adds warnings to test output. (necessary to test warnings for invalid annotation, uncalled functions, etc.)
- introduces
private
visibility for function parameters. (still private by default)
Note: function inlining it not yet supported.
The rules for function and data types are as follows:
- There are three types of functions: "program functions", "helper functions", and "inline functions".
- There are two supported annotations:
@program
and@inline
. - A function cannot have both
@program
and@inline
annotations. - If a function is annotated with
@program
then it is a program function, if it is annotated with@inline
then it is an inline function, otherwise it is a helper function. - Program functions can only call helper functions and inline functions.
- Helper functions can only call inline functions.
- Inline functions can only call inline functions.
- Program functions and helper functions must have at least one parameter.
- Program functions cannot have constant inputs.
- Direct/indirect recursive calls are not allowed.
- There are two types of named composite data types:
circuit
andrecord
. - A named composite data type cannot contain a record as its member.
- Direct/indirect recursive types are not allowed.
Codecov Report
Merging #2008 (608ee01) into testnet3 (66816d4) will increase coverage by
0.59%
. The diff coverage is86.30%
.
:exclamation: Current head 608ee01 differs from pull request most recent head 5a3a6ba. Consider uploading reports for the commit 5a3a6ba to get more accurate results
@@ Coverage Diff @@
## testnet3 #2008 +/- ##
============================================
+ Coverage 81.83% 82.42% +0.59%
============================================
Files 130 132 +2
Lines 5488 5622 +134
Branches 5487 5621 +134
============================================
+ Hits 4491 4634 +143
+ Misses 997 988 -9
Impacted Files | Coverage Δ | |
---|---|---|
compiler/parser/src/tokenizer/mod.rs | 100.00% <ø> (ø) |
|
compiler/passes/src/lib.rs | 100.00% <ø> (ø) |
|
compiler/span/src/symbol.rs | 94.59% <ø> (ø) |
|
compiler/parser/src/tokenizer/token.rs | 68.70% <33.33%> (-0.26%) |
:arrow_down: |
...iler/passes/src/type_checking/check_expressions.rs | 82.19% <74.35%> (+0.18%) |
:arrow_up: |
...rors/src/errors/type_checker/type_checker_error.rs | 65.15% <80.00%> (+4.80%) |
:arrow_up: |
...mpiler/passes/src/symbol_table_creation/creator.rs | 91.89% <91.89%> (ø) |
|
compiler/passes/src/type_checking/check_program.rs | 96.55% <93.93%> (-0.28%) |
:arrow_down: |
compiler/passes/src/common/call_graph/mod.rs | 97.29% <97.29%> (ø) |
|
compiler/compiler/src/compiler.rs | 94.28% <100.00%> (ø) |
|
... and 21 more |
:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more
Implemented by #2178, #2262, #2180, #2179.