Skip to content

[Compiler] Fix function conversion#4517

Merged
SupunS merged 1 commit into
masterfrom
supun/fix-func-conversion
Jul 13, 2026
Merged

[Compiler] Fix function conversion#4517
SupunS merged 1 commit into
masterfrom
supun/fix-func-conversion

Conversation

@SupunS

@SupunS SupunS commented Jul 10, 2026

Copy link
Copy Markdown
Member

Description

The function conversion (type clamping) wasn't preserving the dereferenceReceiver flag.


  • 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

@SupunS SupunS self-assigned this Jul 10, 2026
@github-actions

Copy link
Copy Markdown

Dependency Review

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

Scanned Files

None

@SupunS SupunS added the Bugfix label Jul 10, 2026
@github-actions

Copy link
Copy Markdown

Benchstat comparison

  • Base branch: onflow:master
  • Base commit: 214f064
Results

old.txtnew.txt
time/opdelta
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ByteArrayTransfer-41.79µs ± 0%1.58µs ± 0%~(p=1.000 n=1+1)
ByteArrayValueToByteSlice-482.2ns ± 0%79.2ns ± 0%~(p=1.000 n=1+1)
ByteSliceToByteArrayValue-41.40µs ± 0%1.34µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/bbq/compiler goos:linux goarch:amd64
CompileFungibleTokenTransferTransaction-4137µs ± 0%130µs ± 0%~(p=1.000 n=1+1)
CompileTime-442.6µs ± 0%40.3µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ContractFunctionInvocation-4411µs ± 0%402µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
ContractImport-4265µs ± 0%263µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
EMVAddressTransfer-44.63µs ± 0%4.39µs ± 0%~(p=1.000 n=1+1)
Emit-45.74ms ± 0%5.52ms ± 0%~(p=1.000 n=1+1)
EnumTransfer-42.12µs ± 0%1.80µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ExportType/composite_type-4254ns ± 0%242ns ± 0%~(p=1.000 n=1+1)
ExportType/simple_type-442.6ns ± 0%42.6ns ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
FTTransfer-4191µs ± 0%187µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ImperativeFib-427.9µs ± 0%27.1µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
ImperativeFib-430.8µs ± 0%30.4µs ± 0%~(p=1.000 n=1+1)
ImperativeFibNewCompilerNewVM-460.2µs ± 0%62.8µs ± 0%~(p=1.000 n=1+1)
ImperativeFibNewVM-434.9µs ± 0%34.6µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
InterpretRecursionFib-42.51ms ± 0%2.41ms ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
InterpreterFTTransfer-4148µs ± 0%146µs ± 0%~(p=1.000 n=1+1)
InterpreterImperativeFib-426.6µs ± 0%26.0µs ± 0%~(p=1.000 n=1+1)
InterpreterNewStruct-481.7µs ± 0%76.6µs ± 0%~(p=1.000 n=1+1)
MethodCall/concrete_type_method_call-451.9µs ± 0%52.5µs ± 0%~(p=1.000 n=1+1)
MethodCall/interface_method_call-473.7µs ± 0%70.9µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
NewInterpreter/new_interpreter-4920ns ± 0%894ns ± 0%~(p=1.000 n=1+1)
NewInterpreter/new_sub-interpreter-4337ns ± 0%325ns ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
NewStruct-456.3µs ± 0%55.0µs ± 0%~(p=1.000 n=1+1)
NewStructRaw-44.33µs ± 0%4.24µs ± 0%~(p=1.000 n=1+1)
RecursionFib-41.90ms ± 0%1.89ms ± 0%~(p=1.000 n=1+1)
RuntimeFungibleTokenTransfer-4806µs ± 0%845µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
RuntimeFungibleTokenTransferInterpreter-4673µs ± 0%652µs ± 0%~(p=1.000 n=1+1)
RuntimeResourceDictionaryValues-43.03ms ± 0%2.86ms ± 0%~(p=1.000 n=1+1)
RuntimeResourceTracking-412.0ms ± 0%11.3ms ± 0%~(p=1.000 n=1+1)
RuntimeScriptNoop-415.9µs ± 0%15.8µs ± 0%~(p=1.000 n=1+1)
RuntimeVMInvokeContractImperativeFib-449.2µs ± 0%47.7µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ValueIsSubtypeOfSemaType-461.0ns ± 0%59.2ns ± 0%~(p=1.000 n=1+1)
 
alloc/opdelta
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ByteArrayTransfer-41.19kB ± 0%1.16kB ± 0%~(p=1.000 n=1+1)
ByteArrayValueToByteSlice-432.0B ± 0%32.0B ± 0%~(all equal)
ByteSliceToByteArrayValue-4963B ± 0%967B ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/bbq/compiler goos:linux goarch:amd64
CompileFungibleTokenTransferTransaction-483.5kB ± 0%83.4kB ± 0%~(p=1.000 n=1+1)
CompileTime-417.2kB ± 0%17.2kB ± 0%~(all equal)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ContractFunctionInvocation-4149kB ± 0%149kB ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
ContractImport-480.2kB ± 0%80.1kB ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
EMVAddressTransfer-42.77kB ± 0%2.74kB ± 0%~(p=1.000 n=1+1)
Emit-41.63MB ± 0%1.70MB ± 0%~(p=1.000 n=1+1)
EnumTransfer-41.05kB ± 0%0.98kB ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ExportType/composite_type-4112B ± 0%112B ± 0%~(all equal)
ExportType/simple_type-40.00B 0.00B ~(all equal)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
FTTransfer-446.7kB ± 0%46.7kB ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ImperativeFib-48.30kB ± 0%8.30kB ± 0%~(all equal)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
ImperativeFib-46.30kB ± 0%6.30kB ± 0%~(all equal)
ImperativeFibNewCompilerNewVM-427.0kB ± 0%27.0kB ± 0%~(p=1.000 n=1+1)
ImperativeFibNewVM-49.03kB ± 0%9.03kB ± 0%~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
InterpretRecursionFib-41.17MB ± 0%1.17MB ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
InterpreterFTTransfer-446.3kB ± 0%46.3kB ± 0%~(p=1.000 n=1+1)
InterpreterImperativeFib-48.29kB ± 0%8.29kB ± 0%~(all equal)
InterpreterNewStruct-426.5kB ± 0%26.1kB ± 0%~(p=1.000 n=1+1)
MethodCall/concrete_type_method_call-411.4kB ± 0%11.4kB ± 0%~(p=1.000 n=1+1)
MethodCall/interface_method_call-418.4kB ± 0%18.4kB ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
NewInterpreter/new_interpreter-41.02kB ± 0%1.02kB ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-4232B ± 0%232B ± 0%~(all equal)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
NewStruct-414.8kB ± 0%14.7kB ± 0%~(p=1.000 n=1+1)
NewStructRaw-42.04kB ± 0%1.98kB ± 0%~(p=1.000 n=1+1)
RecursionFib-4342kB ± 0%342kB ± 0%~(all equal)
RuntimeFungibleTokenTransfer-4251kB ± 0%252kB ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
RuntimeFungibleTokenTransferInterpreter-4175kB ± 0%174kB ± 0%~(p=1.000 n=1+1)
RuntimeResourceDictionaryValues-41.82MB ± 0%1.81MB ± 0%~(p=1.000 n=1+1)
RuntimeResourceTracking-47.43MB ± 0%7.42MB ± 0%~(p=1.000 n=1+1)
RuntimeScriptNoop-48.19kB ± 0%8.19kB ± 0%~(p=1.000 n=1+1)
RuntimeVMInvokeContractImperativeFib-415.0kB ± 0%15.0kB ± 0%~(p=1.000 n=1+1)
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/interpreter goos:linux goarch:amd64
ByteArrayTransfer-48.00 ± 0%8.00 ± 0%~(all equal)
ByteArrayValueToByteSlice-41.00 ± 0%1.00 ± 0%~(all equal)
ByteSliceToByteArrayValue-46.00 ± 0%6.00 ± 0%~(all equal)
pkg:github.com/onflow/cadence/bbq/compiler goos:linux goarch:amd64
CompileFungibleTokenTransferTransaction-4581 ± 0%581 ± 0%~(all equal)
CompileTime-4212 ± 0%212 ± 0%~(all equal)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ContractFunctionInvocation-42.28k ± 0%2.28k ± 0%~(all equal)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
ContractImport-41.40k ± 0%1.40k ± 0%~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
EMVAddressTransfer-431.0 ± 0%31.0 ± 0%~(all equal)
Emit-442.0k ± 0%42.0k ± 0%~(p=1.000 n=1+1)
EnumTransfer-414.0 ± 0%14.0 ± 0%~(all equal)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ExportType/composite_type-42.00 ± 0%2.00 ± 0%~(all equal)
ExportType/simple_type-40.00 0.00 ~(all equal)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
FTTransfer-41.49k ± 0%1.49k ± 0%~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ImperativeFib-4176 ± 0%176 ± 0%~(all equal)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
ImperativeFib-4322 ± 0%322 ± 0%~(all equal)
ImperativeFibNewCompilerNewVM-4534 ± 0%534 ± 0%~(all equal)
ImperativeFibNewVM-4365 ± 0%365 ± 0%~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
InterpretRecursionFib-416.5k ± 0%16.5k ± 0%~(all equal)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
InterpreterFTTransfer-41.01k ± 0%1.01k ± 0%~(all equal)
InterpreterImperativeFib-4175 ± 0%175 ± 0%~(all equal)
InterpreterNewStruct-4418 ± 0%418 ± 0%~(all equal)
MethodCall/concrete_type_method_call-4404 ± 0%404 ± 0%~(all equal)
MethodCall/interface_method_call-4514 ± 0%514 ± 0%~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
NewInterpreter/new_interpreter-416.0 ± 0%16.0 ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-44.00 ± 0%4.00 ± 0%~(all equal)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
NewStruct-4432 ± 0%432 ± 0%~(all equal)
NewStructRaw-432.0 ± 0%32.0 ± 0%~(all equal)
RecursionFib-419.5k ± 0%19.5k ± 0%~(all equal)
RuntimeFungibleTokenTransfer-44.22k ± 0%4.22k ± 0%~(all equal)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
RuntimeFungibleTokenTransferInterpreter-43.22k ± 0%3.22k ± 0%~(all equal)
RuntimeResourceDictionaryValues-436.7k ± 0%36.7k ± 0%~(p=1.000 n=1+1)
RuntimeResourceTracking-4131k ± 0%131k ± 0%~(p=1.000 n=1+1)
RuntimeScriptNoop-4117 ± 0%117 ± 0%~(all equal)
RuntimeVMInvokeContractImperativeFib-4489 ± 0%489 ± 0%~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ValueIsSubtypeOfSemaType-41.00 ± 0%1.00 ± 0%~(all equal)
 

@SupunS SupunS marked this pull request as ready for review July 13, 2026 16:02
@SupunS SupunS requested a review from turbolent as a code owner July 13, 2026 16:02
@SupunS SupunS merged commit 64b1ef2 into master Jul 13, 2026
16 of 17 checks passed
@SupunS SupunS deleted the supun/fix-func-conversion branch July 13, 2026 17:21
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.

2 participants