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

Take argument labels into account when declaring members for nested declarations #1717

Merged
merged 1 commit into from Jun 13, 2022

Conversation

turbolent
Copy link
Member

Description

When declaring the members for nested declarations, e.g. a composite declaration inside a contract, also take the argument labels of the nested declaration into account.

This was reported by @justjoolz, who also provided a great reproduction in https://github.com/justjoolz/struct-test 🙏


  • 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
Copy link

codecov bot commented Jun 12, 2022

Codecov Report

Merging #1717 (abcb205) into master (f4bc9b2) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1717      +/-   ##
==========================================
- Coverage   77.00%   76.99%   -0.02%     
==========================================
  Files         292      292              
  Lines       61187    61212      +25     
==========================================
+ Hits        47117    47130      +13     
- Misses      12459    12469      +10     
- Partials     1611     1613       +2     
Flag Coverage Δ
unittests 76.99% <100.00%> (-0.02%) ⬇️

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

Impacted Files Coverage Δ
runtime/sema/check_composite_declaration.go 95.64% <100.00%> (+<0.01%) ⬆️
runtime/parser2/errors.go 19.17% <0.00%> (-1.72%) ⬇️
runtime/parser2/parser.go 91.18% <0.00%> (-0.76%) ⬇️
runtime/runtime.go 86.47% <0.00%> (-0.04%) ⬇️
runtime/parser2/function.go 73.63% <0.00%> (+0.39%) ⬆️

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 f4bc9b2...abcb205. Read the comment docs.

@github-actions
Copy link

Cadence Benchstat comparison

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

Results

old.txtnew.txt
time/opdelta
CheckContractInterfaceFungibleTokenConformance-2143µs ± 5%139µs ± 2%~(p=0.053 n=7+7)
ContractInterfaceFungibleToken-242.3µs ± 1%42.1µs ± 1%~(p=0.366 n=7+6)
InterpretRecursionFib-22.92ms ± 1%2.95ms ± 2%~(p=0.181 n=6+7)
NewInterpreter/new_interpreter-21.12µs ± 7%1.09µs ± 1%~(p=0.618 n=7+7)
NewInterpreter/new_sub-interpreter-22.31µs ± 1%2.37µs ± 8%~(p=0.929 n=7+7)
ParseArray-28.70ms ± 1%8.67ms ± 1%~(p=0.394 n=6+6)
ParseDeploy/byte_array-213.1ms ± 1%13.6ms ± 5%+3.26%(p=0.002 n=6+7)
ParseDeploy/decode_hex-21.16ms ± 1%1.15ms ± 1%~(p=0.073 n=7+6)
ParseFungibleToken/With_memory_metering-2212µs ± 1%210µs ± 1%~(p=0.181 n=7+6)
ParseFungibleToken/Without_memory_metering-2164µs ± 4%162µs ± 2%~(p=0.209 n=7+7)
ParseInfix-27.70µs ± 1%7.69µs ± 1%~(p=0.983 n=7+7)
QualifiedIdentifierCreation/One_level-22.35ns ± 0%2.35ns ± 0%~(p=0.849 n=7+7)
QualifiedIdentifierCreation/Three_levels-2143ns ± 1%142ns ± 2%~(p=0.050 n=7+7)
RuntimeFungibleTokenTransfer-21.22ms ±20%1.16ms ±26%~(p=0.535 n=7+7)
RuntimeResourceDictionaryValues-26.65ms ± 4%6.63ms ± 4%~(p=0.805 n=7+7)
Transfer-288.6ns ± 2%88.8ns ± 1%~(p=0.559 n=7+6)
 
alloc/opdelta
CheckContractInterfaceFungibleTokenConformance-266.3kB ± 0%66.3kB ± 0%~(p=1.000 n=7+7)
ContractInterfaceFungibleToken-226.7kB ± 0%26.7kB ± 0%~(all equal)
InterpretRecursionFib-21.25MB ± 0%1.25MB ± 0%~(p=0.286 n=7+7)
NewInterpreter/new_interpreter-2872B ± 0%872B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-21.38kB ± 0%1.38kB ± 0%~(all equal)
ParseArray-22.81MB ± 2%2.79MB ± 2%~(p=0.198 n=7+7)
ParseDeploy/byte_array-24.33MB ± 0%4.53MB ± 0%+4.57%(p=0.004 n=6+5)
ParseDeploy/decode_hex-2214kB ± 0%214kB ± 0%~(p=0.080 n=6+7)
ParseFungibleToken/With_memory_metering-236.3kB ± 0%36.3kB ± 0%+0.03%(p=0.017 n=7+6)
ParseFungibleToken/Without_memory_metering-236.3kB ± 0%36.3kB ± 0%~(p=0.124 n=7+6)
ParseInfix-22.17kB ± 0%2.17kB ± 0%~(p=0.148 n=6+7)
QualifiedIdentifierCreation/One_level-20.00B 0.00B ~(all equal)
QualifiedIdentifierCreation/Three_levels-264.0B ± 0%64.0B ± 0%~(all equal)
RuntimeFungibleTokenTransfer-2236kB ± 0%236kB ± 0%~(p=0.534 n=7+6)
RuntimeResourceDictionaryValues-22.25MB ± 0%2.25MB ± 0%~(p=0.402 n=7+7)
Transfer-248.0B ± 0%48.0B ± 0%~(all equal)
 
allocs/opdelta
CheckContractInterfaceFungibleTokenConformance-21.07k ± 0%1.07k ± 0%~(all equal)
ContractInterfaceFungibleToken-2460 ± 0%460 ± 0%~(all equal)
InterpretRecursionFib-223.8k ± 0%23.8k ± 0%~(all equal)
NewInterpreter/new_interpreter-212.0 ± 0%12.0 ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-240.0 ± 0%40.0 ± 0%~(all equal)
ParseArray-270.0k ± 0%70.0k ± 0%~(p=1.000 n=7+7)
ParseDeploy/byte_array-2105k ± 0%105k ± 0%~(p=1.000 n=7+7)
ParseDeploy/decode_hex-278.0 ± 0%78.0 ± 0%~(all equal)
ParseFungibleToken/With_memory_metering-21.06k ± 0%1.06k ± 0%~(all equal)
ParseFungibleToken/Without_memory_metering-21.06k ± 0%1.06k ± 0%~(all equal)
ParseInfix-266.0 ± 0%66.0 ± 0%~(all equal)
QualifiedIdentifierCreation/One_level-20.00 0.00 ~(all equal)
QualifiedIdentifierCreation/Three_levels-22.00 ± 0%2.00 ± 0%~(all equal)
RuntimeFungibleTokenTransfer-24.52k ± 0%4.52k ± 0%~(p=0.780 n=7+7)
RuntimeResourceDictionaryValues-237.6k ± 0%37.6k ± 0%~(p=0.557 n=7+7)
Transfer-21.00 ± 0%1.00 ± 0%~(all equal)
 

@turbolent turbolent added the Language Breaking Change Breaks Cadence contracts deployed on Mainnet label Jun 13, 2022
@turbolent turbolent merged commit 3ee1aa8 into master Jun 13, 2022
@turbolent turbolent deleted the bastian/fix-argument-labels-nested-constructors branch June 13, 2022 18:05
bors bot added a commit to onflow/flow-go that referenced this pull request Jun 21, 2022
2653: Fix Cadence code r=turbolent a=turbolent

In github.com/onflow/cadence#1717, the check of argument labels for nested constructors was fixed.
Fix the previously accepted code, which is now rejected:
- Update to the fixed core contracts
- Add the missing argument label


Co-authored-by: Bastian Müller <bastian@axiomzen.co>
bors bot added a commit to onflow/flow-go that referenced this pull request Jun 23, 2022
2653: Fix Cadence code r=turbolent a=turbolent

In github.com/onflow/cadence#1717, the check of argument labels for nested constructors was fixed.
Fix the previously accepted code, which is now rejected:
- Update to the fixed core contracts
- Add the missing argument label


Co-authored-by: Bastian Müller <bastian@axiomzen.co>
bors bot added a commit to onflow/flow-go that referenced this pull request Jun 28, 2022
2653: Fix Cadence code r=turbolent a=turbolent

In github.com/onflow/cadence#1717, the check of argument labels for nested constructors was fixed.
Fix the previously accepted code, which is now rejected:
- Update to the fixed core contracts
- Add the missing argument label


Co-authored-by: Bastian Müller <bastian@axiomzen.co>
Co-authored-by: Daniel Sainati <sainatidaniel@gmail.com>
@turbolent turbolent mentioned this pull request Jul 22, 2022
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bugfix Language Breaking Change Breaks Cadence contracts deployed on Mainnet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants