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

Don't report errors for invalid types #1597

Merged
merged 2 commits into from
Apr 21, 2022
Merged

Conversation

turbolent
Copy link
Member

Description

While analyzing contracts I noticed several unnecessary error messages for invalid types, which are results for previous errors.

Just like everywhere else already, don't report errors for unexpected invalid types for:

  • Unary expressions, e.g. for unary negation.
    Reported an error like expected Bool, got <<invalid>>
  • Optional-binding variable declaration (e.g if let nonOpt = opt { ... }).
    Reported an error like expected optional, got <<invalid>>

  • 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

Copy link
Contributor

@dsainati1 dsainati1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some tests that previously would have reported an invalid type error and now do not?

@codecov
Copy link

codecov bot commented Apr 20, 2022

Codecov Report

Merging #1597 (1004a81) into master (1216be2) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1597      +/-   ##
==========================================
- Coverage   74.74%   74.73%   -0.01%     
==========================================
  Files         288      288              
  Lines       55340    55340              
==========================================
- Hits        41362    41357       -5     
- Misses      12486    12489       +3     
- Partials     1492     1494       +2     
Flag Coverage Δ
unittests 74.73% <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_unary_expression.go 91.07% <100.00%> (-0.31%) ⬇️
runtime/sema/check_variable_declaration.go 95.40% <100.00%> (+0.05%) ⬆️
runtime/interpreter/storage.go 71.42% <0.00%> (-1.37%) ⬇️
runtime/sema/checker.go 90.48% <0.00%> (-0.12%) ⬇️
runtime/sema/type.go 88.58% <0.00%> (-0.09%) ⬇️
runtime/sema/simple_type.go 96.15% <0.00%> (+3.84%) ⬆️

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 1216be2...1004a81. Read the comment docs.

@github-actions
Copy link

github-actions bot commented Apr 20, 2022

Cadence Benchstat comparison

This branch with compared with the base branch onflow:master commit 1216be2
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
ParseInfix-210.0µs ± 3%10.4µs ± 5%+3.67%(p=0.007 n=7+7)
QualifiedIdentifierCreation/One_level-23.29ns ± 0%3.37ns ± 3%+2.57%(p=0.008 n=6+7)
CheckContractInterfaceFungibleTokenConformance-2172µs ± 1%175µs ± 3%+1.71%(p=0.003 n=5+7)
RuntimeFungibleTokenTransfer-21.41ms ±28%1.41ms ±35%~(p=1.000 n=7+7)
RuntimeResourceDictionaryValues-27.81ms ± 6%7.61ms ± 4%~(p=0.209 n=7+7)
Transfer-2107ns ± 2%106ns ± 1%~(p=0.331 n=6+6)
ParseFungibleToken-2225µs ± 1%228µs ± 2%~(p=0.065 n=6+6)
ParseArray-214.7ms ± 2%15.1ms ± 5%~(p=0.209 n=7+7)
ParseDeploy/byte_array-222.9ms ± 2%23.1ms ± 4%~(p=0.836 n=7+6)
ParseDeploy/decode_hex-21.45ms ± 1%1.49ms ± 4%~(p=0.138 n=6+7)
ContractInterfaceFungibleToken-248.3µs ± 3%49.2µs ± 4%~(p=0.295 n=7+6)
NewInterpreter/new_interpreter-21.36µs ± 1%1.35µs ± 2%~(p=0.979 n=7+6)
NewInterpreter/new_sub-interpreter-22.68µs ± 4%2.62µs ± 1%~(p=0.073 n=7+6)
InterpretRecursionFib-23.12ms ± 2%3.18ms ± 3%~(p=0.138 n=6+7)
QualifiedIdentifierCreation/Three_levels-2177ns ± 3%166ns ± 2%−6.02%(p=0.001 n=7+7)
 
alloc/opdelta
RuntimeFungibleTokenTransfer-2273kB ± 0%273kB ± 0%~(p=0.097 n=7+7)
RuntimeResourceDictionaryValues-22.25MB ± 0%2.25MB ± 0%~(p=0.978 n=6+7)
Transfer-248.0B ± 0%48.0B ± 0%~(all equal)
QualifiedIdentifierCreation/One_level-20.00B 0.00B ~(all equal)
QualifiedIdentifierCreation/Three_levels-264.0B ± 0%64.0B ± 0%~(all equal)
ContractInterfaceFungibleToken-226.7kB ± 0%26.7kB ± 0%~(all equal)
CheckContractInterfaceFungibleTokenConformance-266.3kB ± 0%66.3kB ± 0%~(all equal)
NewInterpreter/new_interpreter-2848B ± 0%848B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-21.34kB ± 0%1.34kB ± 0%~(all equal)
InterpretRecursionFib-21.14MB ± 0%1.14MB ± 0%~(p=1.000 n=7+5)
 
allocs/opdelta
RuntimeFungibleTokenTransfer-24.58k ± 0%4.58k ± 0%~(p=1.000 n=7+7)
RuntimeResourceDictionaryValues-237.6k ± 0%37.6k ± 0%~(p=0.895 n=7+7)
Transfer-21.00 ± 0%1.00 ± 0%~(all equal)
QualifiedIdentifierCreation/One_level-20.00 0.00 ~(all equal)
QualifiedIdentifierCreation/Three_levels-22.00 ± 0%2.00 ± 0%~(all equal)
ContractInterfaceFungibleToken-2460 ± 0%460 ± 0%~(all equal)
CheckContractInterfaceFungibleTokenConformance-21.07k ± 0%1.07k ± 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)
InterpretRecursionFib-223.8k ± 0%23.8k ± 0%~(all equal)
 

@turbolent
Copy link
Member Author

Added tests in 1004a81

@turbolent turbolent merged commit aa2ae0d into master Apr 21, 2022
@turbolent turbolent deleted the bastian/improve-errors branch April 21, 2022 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants