Skip to content

Improve AST walking - #4434

Merged
turbolent merged 5 commits into
masterfrom
bastian/improve-ast-walking
Feb 10, 2026
Merged

turbolent merged 5 commits into
masterfrom
bastian/improve-ast-walking

Conversation

@turbolent

@turbolent turbolent commented Feb 6, 2026 •

Copy link
Copy Markdown
Member

Description

Tooling like analyzers (e.g. used in the linter) might want to find all type annotations / types.

Make types and type annotations elements, and implement walking for them. Also add walking for parameter lists, so all type annotations are visited, and add missing walking over transaction conditions.

Finally, add tests for all walking functions.


  • 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

@turbolent turbolent self-assigned this Feb 6, 2026
@github-actions

github-actions Bot commented Feb 6, 2026 •

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions

github-actions Bot commented Feb 6, 2026 •

Copy link
Copy Markdown

Benchstat comparison

  • Base branch: onflow:master
  • Base commit: 8f2f949
Results

old.txtnew.txt
time/opdelta
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ContractFunctionInvocation-4420µs ± 0%403µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
Emit-44.57ms ± 0%4.66ms ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ExportType/composite_type-4269ns ± 0%264ns ± 0%~(p=1.000 n=1+1)
ExportType/simple_type-477.5ns ± 0%78.1ns ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ImperativeFib-422.6µs ± 0%22.5µs ± 0%~(p=1.000 n=1+1)
InterpretRecursionFib-42.20ms ± 0%2.22ms ± 0%~(p=1.000 n=1+1)
NewInterpreter/new_interpreter-4851ns ± 0%863ns ± 0%~(p=1.000 n=1+1)
NewInterpreter/new_sub-interpreter-4326ns ± 0%324ns ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
RuntimeFungibleTokenTransferInterpreter-4636µs ± 0%640µs ± 0%~(p=1.000 n=1+1)
RuntimeFungibleTokenTransferVM-4711µs ± 0%707µs ± 0%~(p=1.000 n=1+1)
RuntimeResourceDictionaryValues-42.67ms ± 0%2.62ms ± 0%~(p=1.000 n=1+1)
RuntimeResourceTracking-411.5ms ± 0%11.2ms ± 0%~(p=1.000 n=1+1)
RuntimeScriptNoop-414.8µs ± 0%14.7µs ± 0%~(p=1.000 n=1+1)
RuntimeVMInvokeContractImperativeFib-440.8µs ± 0%41.9µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ValueIsSubtypeOfSemaType-463.9ns ± 0%60.9ns ± 0%~(p=1.000 n=1+1)
 
alloc/opdelta
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ContractFunctionInvocation-4153kB ± 0%152kB ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
Emit-41.50MB ± 0%1.50MB ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ExportType/composite_type-4120B ± 0%120B ± 0%~(all equal)
ExportType/simple_type-40.00B 0.00B ~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ImperativeFib-48.30kB ± 0%8.30kB ± 0%~(all equal)
InterpretRecursionFib-41.19MB ± 0%1.19MB ± 0%~(p=1.000 n=1+1)
NewInterpreter/new_interpreter-4976B ± 0%976B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-4232B ± 0%232B ± 0%~(all equal)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
RuntimeFungibleTokenTransferInterpreter-4170kB ± 0%170kB ± 0%~(p=1.000 n=1+1)
RuntimeFungibleTokenTransferVM-4192kB ± 0%192kB ± 0%~(p=1.000 n=1+1)
RuntimeResourceDictionaryValues-41.76MB ± 0%1.76MB ± 0%~(p=1.000 n=1+1)
RuntimeResourceTracking-48.61MB ± 0%8.59MB ± 0%~(p=1.000 n=1+1)
RuntimeScriptNoop-48.05kB ± 0%8.06kB ± 0%~(p=1.000 n=1+1)
RuntimeVMInvokeContractImperativeFib-413.3kB ± 0%13.3kB ± 0%~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ValueIsSubtypeOfSemaType-432.0B ± 0%32.0B ± 0%~(all equal)
 
allocs/opdelta
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ContractFunctionInvocation-42.47k ± 0%2.47k ± 0%~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
Emit-440.0k ± 0%40.0k ± 0%~(all equal)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ExportType/composite_type-43.00 ± 0%3.00 ± 0%~(all equal)
ExportType/simple_type-40.00 0.00 ~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ImperativeFib-4176 ± 0%176 ± 0%~(all equal)
InterpretRecursionFib-417.7k ± 0%17.7k ± 0%~(all equal)
NewInterpreter/new_interpreter-415.0 ± 0%15.0 ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-44.00 ± 0%4.00 ± 0%~(all equal)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
RuntimeFungibleTokenTransferInterpreter-43.27k ± 0%3.27k ± 0%~(all equal)
RuntimeFungibleTokenTransferVM-43.72k ± 0%3.72k ± 0%~(all equal)
RuntimeResourceDictionaryValues-436.7k ± 0%36.7k ± 0%~(all equal)
RuntimeResourceTracking-4144k ± 0%144k ± 0%~(p=1.000 n=1+1)
RuntimeScriptNoop-4114 ± 0%114 ± 0%~(all equal)
RuntimeVMInvokeContractImperativeFib-4424 ± 0%424 ± 0%~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ValueIsSubtypeOfSemaType-41.00 ± 0%1.00 ± 0%~(all equal)
 

@turbolent turbolent changed the title Walk type annotations, make type annotations elements Improve AST walking Feb 7, 2026

@SupunS SupunS left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice!

@turbolent
turbolent merged commit 57296b9 into master Feb 10, 2026
15 of 17 checks passed
@turbolent
turbolent deleted the bastian/improve-ast-walking branch April 21, 2026 18:15
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.

2 participants

⌂ 换网址