leo icon indicating copy to clipboard operation
leo copied to clipboard

Check for Nested Record

Open d0cd opened this issue 1 year ago • 2 comments

This PR

  • Checks that a record does not contain a record.
  • Fixes codegen for records that contain circuits.

d0cd avatar Aug 11 '22 07:08 d0cd

Codecov Report

Merging #2015 (fbf0a0a) into testnet3 (322fd1a) will increase coverage by 0.34%. The diff coverage is 79.79%.

@@             Coverage Diff              @@
##           testnet3    #2015      +/-   ##
============================================
+ Coverage     81.88%   82.23%   +0.34%     
============================================
  Files           130      131       +1     
  Lines          5488     5455      -33     
  Branches       5487     5454      -33     
============================================
- Hits           4494     4486       -8     
+ Misses          994      969      -25     
Impacted Files Coverage Δ
compiler/core/src/algorithms/mod.rs 85.54% <ø> (ø)
compiler/passes/src/loop_unrolling/unroller.rs 77.64% <10.00%> (ø)
compiler/ast/src/value/mod.rs 21.69% <19.04%> (+0.74%) :arrow_up:
...iler/passes/src/loop_unrolling/unroll_statement.rs 82.50% <50.00%> (ø)
...iler/passes/src/type_checking/check_expressions.rs 85.45% <84.05%> (+3.44%) :arrow_up:
compiler/parser/src/parser/type_.rs 97.29% <95.65%> (+0.42%) :arrow_up:
compiler/ast/src/expressions/literal.rs 93.33% <100.00%> (-3.16%) :arrow_down:
compiler/ast/src/types/integer_type.rs 100.00% <100.00%> (ø)
compiler/ast/src/types/type_.rs 85.18% <100.00%> (-0.11%) :arrow_down:
compiler/parser/src/parser/expression.rs 94.83% <100.00%> (+0.27%) :arrow_up:
... and 10 more

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov[bot] avatar Aug 11 '22 08:08 codecov[bot]

Right, it makes sense for records to be only at the top level, since they are exchanged with the external world. I'll need to add this requirement to the Leo Reference. I believe that the requirement can be expressed by saying that no circuit component declaration (which is used in both circuit declarations and record declarations) can have (1) a record type or (2) a tuple type one of whose components isa record type or (3) an array type (future) whose element type is a record type (here I'm using 'element' vs. 'component' in an array in the same way as Java, e.g. the component type of [[T; N]; M], with T not an array type, is [T; N] but its element type is T). Does this seem to cover all cases, by implication? If a record type has a component with a circuit type C, that cannot contain a record because the check applies to the component declarations of C separately. This seems consistent with @d0cd's notes above.

acoglio avatar Aug 11 '22 17:08 acoglio

@d0cd this is good to merge after conflicts are fixed.

collinc97 avatar Aug 15 '22 23:08 collinc97