Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix field initialization: nested intersection should not override outer set #1524

Merged
merged 1 commit into from
Mar 23, 2022

Conversation

turbolent
Copy link
Member

Closes #1523

Description

If-statement branches are checked using Checker.checkConditionalBranches.
It temporarily creates a new child member set, checks each branch with the temporary member set (using Checker.checkWithInitializedMembers, then "merges" the result by building an intersection (a field is considered initialized if it was initialized in both branches).

The existing implementation was overwriting the outer if-statements member set.

Instead, mutate the current member set in-place when computing the intersection.


  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

@codecov-commenter
Copy link

Codecov Report

Merging #1524 (86f8b58) into master (5238cce) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #1524   +/-   ##
=======================================
  Coverage   74.68%   74.68%           
=======================================
  Files         289      289           
  Lines       55607    55602    -5     
=======================================
  Hits        41528    41528           
+ Misses      12584    12580    -4     
+ Partials     1495     1494    -1     
Flag Coverage Δ
unittests 74.68% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
runtime/sema/check_conditional.go 93.66% <100.00%> (ø)
runtime/sema/member_set.go 93.75% <100.00%> (-0.59%) ⬇️
runtime/sema/ordered_map_member_struct.go 49.29% <0.00%> (+7.04%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5238cce...86f8b58. Read the comment docs.

@github-actions
Copy link

Cadence Benchstat comparison

This branch with compared with the base branch onflow:master commit 668062c
The command for i in {1..N}; do go test ./... -run=XXX -bench=. -shuffle=on; done was used.
Bench tests were run a total of 7 times on each branch.

Results

old.txtnew.txt
time/opdelta
RuntimeFungibleTokenTransfer-21.55ms ±24%1.54ms ±24%~(p=0.805 n=7+7)
RuntimeResourceDictionaryValues-217.0ms ± 4%16.9ms ± 3%~(p=1.000 n=7+7)
ParseArray-218.4ms ± 2%18.6ms ± 6%~(p=0.628 n=6+7)
ParseInfix-210.0µs ± 2%10.2µs ± 3%~(p=0.209 n=7+7)
ParseDeploy/byte_array-230.8ms ± 9%31.2ms ± 6%~(p=0.902 n=7+7)
ParseDeploy/decode_hex-21.43ms ± 1%1.43ms ± 1%~(p=0.445 n=6+7)
ParseFungibleToken-2224µs ± 4%226µs ± 3%~(p=0.535 n=7+7)
QualifiedIdentifierCreation/One_level-22.81ns ± 0%2.80ns ± 1%~(p=0.383 n=6+7)
CheckContractInterfaceFungibleTokenConformance-2161µs ± 1%161µs ± 3%~(p=0.620 n=7+7)
ContractInterfaceFungibleToken-249.1µs ± 4%48.8µs ± 3%~(p=0.620 n=7+7)
InterpretRecursionFib-23.26ms ± 5%3.33ms ± 3%~(p=0.128 n=7+7)
NewInterpreter/new_interpreter-21.38µs ± 4%1.40µs ± 3%~(p=0.383 n=7+7)
NewInterpreter/new_sub-interpreter-22.74µs ± 4%2.73µs ± 1%~(p=0.684 n=7+7)
QualifiedIdentifierCreation/Three_levels-2171ns ± 2%168ns ± 2%−1.87%(p=0.011 n=7+7)
 
alloc/opdelta
RuntimeFungibleTokenTransfer-2273kB ± 0%273kB ± 0%~(p=0.165 n=7+7)
RuntimeResourceDictionaryValues-24.05MB ± 0%4.05MB ± 0%~(p=0.477 n=7+7)
QualifiedIdentifierCreation/One_level-20.00B 0.00B ~(all equal)
QualifiedIdentifierCreation/Three_levels-264.0B ± 0%64.0B ± 0%~(all equal)
CheckContractInterfaceFungibleTokenConformance-266.2kB ± 0%66.2kB ± 0%~(all equal)
ContractInterfaceFungibleToken-226.6kB ± 0%26.6kB ± 0%~(p=0.592 n=7+7)
InterpretRecursionFib-21.26MB ± 0%1.26MB ± 0%~(all equal)
NewInterpreter/new_interpreter-2848B ± 0%848B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-21.34kB ± 0%1.34kB ± 0%~(all equal)
 
allocs/opdelta
RuntimeFungibleTokenTransfer-24.54k ± 0%4.54k ± 0%~(p=1.000 n=7+7)
RuntimeResourceDictionaryValues-2102k ± 0%102k ± 0%~(p=0.272 n=7+7)
QualifiedIdentifierCreation/One_level-20.00 0.00 ~(all equal)
QualifiedIdentifierCreation/Three_levels-22.00 ± 0%2.00 ± 0%~(all equal)
CheckContractInterfaceFungibleTokenConformance-21.07k ± 0%1.07k ± 0%~(all equal)
ContractInterfaceFungibleToken-2458 ± 0%458 ± 0%~(all equal)
InterpretRecursionFib-226.2k ± 0%26.2k ± 0%~(all equal)
NewInterpreter/new_interpreter-213.0 ± 0%13.0 ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-240.0 ± 0%40.0 ± 0%~(all equal)
 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

initialization of field '...' in type 'Transaction'. not initialized
4 participants