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

Refactor parser to always return syntax errors #1764

Merged
merged 3 commits into from
Jul 8, 2022

Conversation

SupunS
Copy link
Member

@SupunS SupunS commented Jun 24, 2022

Closes #1650

Description

Depends on #1718 and #1746


  • 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

Base automatically changed from supun/parser-error-refactor to master July 6, 2022 18:32
@codecov
Copy link

codecov bot commented Jul 6, 2022

Codecov Report

Merging #1764 (3f08026) into master (6eaed7e) will decrease coverage by 0.33%.
The diff coverage is 63.86%.

@@            Coverage Diff             @@
##           master    #1764      +/-   ##
==========================================
- Coverage   77.37%   77.04%   -0.34%     
==========================================
  Files         305      305              
  Lines       62677    63043     +366     
==========================================
+ Hits        48498    48569      +71     
- Misses      12558    12757     +199     
- Partials     1621     1717      +96     
Flag Coverage Δ
unittests 77.04% <63.86%> (-0.34%) ⬇️

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

Impacted Files Coverage Δ
runtime/parser/transaction.go 68.30% <32.69%> (-14.31%) ⬇️
runtime/parser/function.go 67.41% <45.00%> (-3.41%) ⬇️
runtime/parser/statement.go 80.20% <53.43%> (-13.16%) ⬇️
runtime/parser/declaration.go 84.61% <64.02%> (-4.76%) ⬇️
runtime/parser/type.go 84.07% <68.45%> (-5.00%) ⬇️
runtime/parser/expression.go 87.83% <70.07%> (-4.83%) ⬇️
runtime/parser/parser.go 89.09% <100.00%> (-0.76%) ⬇️
... and 4 more

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 6eaed7e...3f08026. Read the comment docs.

@github-actions
Copy link

github-actions bot commented Jul 6, 2022

Cadence Benchstat comparison

This branch with compared with the base branch onflow:master commit 6d1ce5a
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.

Collapsed results for better readability

old.txtnew.txt
time/opdelta
CheckContractInterfaceFungibleTokenConformance-2204µs ± 8%204µs ± 6%~(p=0.620 n=7+7)
ContractInterfaceFungibleToken-258.5µs ± 8%57.5µs ±10%~(p=0.318 n=7+7)
InterpretRecursionFib-25.75ms ± 7%5.72ms ± 7%~(p=0.902 n=7+7)
NewInterpreter/new_interpreter-21.48µs ± 2%1.49µs ± 2%~(p=0.628 n=6+7)
NewInterpreter/new_sub-interpreter-23.07µs ± 3%3.05µs ± 2%~(p=0.366 n=7+6)
ParseArray-211.1ms ± 2%11.0ms ± 2%~(p=0.240 n=6+6)
ParseDeploy/byte_array-216.8ms ± 2%16.6ms ± 1%−1.58%(p=0.041 n=6+6)
ParseDeploy/decode_hex-21.58ms ± 4%1.55ms ± 2%~(p=0.101 n=7+6)
ParseFungibleToken/With_memory_metering-2279µs ± 2%282µs ± 5%~(p=0.366 n=6+7)
ParseFungibleToken/Without_memory_metering-2212µs ± 6%211µs ± 4%~(p=0.902 n=7+7)
ParseInfix-29.76µs ± 3%9.76µs ± 2%~(p=0.731 n=7+6)
QualifiedIdentifierCreation/One_level-23.63ns ± 2%3.63ns ± 3%~(p=0.902 n=7+7)
QualifiedIdentifierCreation/Three_levels-2192ns ± 1%194ns ± 2%~(p=0.165 n=7+7)
RuntimeFungibleTokenTransfer-21.32ms ± 2%1.44ms ±23%~(p=0.366 n=6+7)
RuntimeResourceDictionaryValues-27.99ms ± 1%8.11ms ± 3%~(p=0.181 n=6+7)
ValueIsSubtypeOfSemaType-2117ns ± 1%119ns ± 3%~(p=0.218 n=6+7)
 
alloc/opdelta
CheckContractInterfaceFungibleTokenConformance-267.0kB ± 0%67.0kB ± 0%~(p=0.462 n=7+7)
ContractInterfaceFungibleToken-226.8kB ± 0%26.8kB ± 0%~(all equal)
InterpretRecursionFib-21.51MB ± 0%1.51MB ± 0%~(p=0.147 n=7+7)
NewInterpreter/new_interpreter-2928B ± 0%928B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-21.46kB ± 0%1.46kB ± 0%~(all equal)
ParseArray-22.82MB ± 2%2.79MB ± 3%~(p=0.209 n=7+7)
ParseDeploy/byte_array-24.44MB ± 3%4.44MB ± 3%~(p=0.620 n=7+7)
ParseDeploy/decode_hex-2214kB ± 0%214kB ± 0%~(p=0.082 n=6+7)
ParseFungibleToken/With_memory_metering-236.3kB ± 0%36.3kB ± 0%~(p=0.633 n=7+7)
ParseFungibleToken/Without_memory_metering-236.3kB ± 0%36.3kB ± 0%~(p=0.232 n=7+7)
ParseInfix-22.17kB ± 0%2.17kB ± 0%~(p=1.000 n=7+7)
QualifiedIdentifierCreation/One_level-20.00B 0.00B ~(all equal)
QualifiedIdentifierCreation/Three_levels-264.0B ± 0%64.0B ± 0%~(all equal)
RuntimeFungibleTokenTransfer-2232kB ± 0%232kB ± 0%~(p=0.875 n=7+7)
RuntimeResourceDictionaryValues-22.25MB ± 0%2.25MB ± 0%~(p=0.366 n=7+6)
ValueIsSubtypeOfSemaType-248.0B ± 0%48.0B ± 0%~(all equal)
 
allocs/opdelta
CheckContractInterfaceFungibleTokenConformance-21.08k ± 0%1.08k ± 0%~(all equal)
ContractInterfaceFungibleToken-2461 ± 0%461 ± 0%~(all equal)
InterpretRecursionFib-233.5k ± 0%33.5k ± 0%~(all equal)
NewInterpreter/new_interpreter-213.0 ± 0%13.0 ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-242.0 ± 0%42.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-277.0 ± 0%77.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.19k ± 0%4.19k ± 0%~(p=0.678 n=6+7)
RuntimeResourceDictionaryValues-237.5k ± 0%37.5k ± 0%~(p=0.580 n=6+7)
ValueIsSubtypeOfSemaType-21.00 ± 0%1.00 ± 0%~(all equal)
 

Copy link
Member

@turbolent turbolent left a comment

Choose a reason for hiding this comment

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

Great work!

runtime/parser/expression.go Outdated Show resolved Hide resolved
runtime/parser/expression.go Outdated Show resolved Hide resolved
runtime/parser/transaction.go Outdated Show resolved Hide resolved
runtime/parser/expression.go Outdated Show resolved Hide resolved
@SupunS SupunS requested a review from turbolent July 6, 2022 19:58
@SupunS SupunS force-pushed the supun/return-parser-errors branch from 30f9a81 to 3f08026 Compare July 6, 2022 20:49
Copy link
Member

@turbolent turbolent left a comment

Choose a reason for hiding this comment

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

Great work! 👍

@SupunS SupunS merged commit 6e2fb2f into master Jul 8, 2022
@SupunS SupunS deleted the supun/return-parser-errors branch July 8, 2022 14:49
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.

Refactor parser from using panics to error return values
3 participants