Skip to content

Comments

Port #4397: Check move operator for resource-typed extra arguments#4399

Closed
Copilot wants to merge 3 commits intomasterfrom
copilot/port-pull-4397-to-master
Closed

Port #4397: Check move operator for resource-typed extra arguments#4399
Copilot wants to merge 3 commits intomasterfrom
copilot/port-pull-4397-to-master

Conversation

Copy link
Contributor

Copilot AI commented Jan 4, 2026

Description

Ports the fix from #4397 (merged to v1.8) to master. Extends move operator validation to cover variadic arguments in function invocations.

Previously, only required parameters were checked for proper move semantics when passing resources. Variadic arguments bypassed this validation, allowing invalid resource moves or missing move operators to go undetected.

Changes:

  • sema/check_invocation_expression.go: Call checkInvocationArgumentMove for extra arguments
  • sema/account_test.go: Added tests verifying move operator validation on resource-typed variadic arguments

Example:

access(all) resource R {
    access(all) fun addToAccount(_ account: auth(Contracts) &Account) {
        account.contracts.add(
            name: "foo",
            code: "012".decodeHex(),
            <- self,  // Now properly rejected: cannot move self
        )
    }
}

  • 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
Original prompt

Port #4397 to master


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 4, 2026 17:53
Co-authored-by: turbolent <51661+turbolent@users.noreply.github.com>
Co-authored-by: turbolent <51661+turbolent@users.noreply.github.com>
Copilot AI changed the title [WIP] Port changes from pull request 4397 to master branch Port #4397: Check move operator for resource-typed extra arguments Jan 4, 2026
Copilot AI requested a review from turbolent January 4, 2026 17:55
@turbolent
Copy link
Member

@copilot Compare the diff of the new PR with the diff of the original PR

Copy link
Contributor Author

Copilot AI commented Jan 4, 2026

@copilot Compare the diff of the new PR with the diff of the original PR

Comparison complete:

Code changes are identical between the original PR #4397 and this port to master. Both PRs modify:

  • sema/check_invocation_expression.go: Add checkInvocationArgumentMove call for extra arguments (6 lines changed)
  • sema/account_test.go: Add 2 test cases for resource move validation (42 lines added)

Only difference:

The git index hashes differ due to different base commits (v1.8 vs master), but the actual code changes are functionally identical.

@github-actions
Copy link

github-actions bot commented Jan 5, 2026

Dependency Review

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

Scanned Files

None

@github-actions
Copy link

github-actions bot commented Jan 5, 2026

Benchstat comparison

  • Base branch: onflow:master
  • Base commit: d6e33c4
Results

old.txtnew.txt
time/opdelta
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ContractFunctionInvocation-4402µs ± 0%415µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
Emit-44.25ms ± 0%4.17ms ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ExportType/composite_type-4266ns ± 0%276ns ± 0%~(p=1.000 n=1+1)
ExportType/simple_type-477.6ns ± 0%78.2ns ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/sema goos:linux goarch:amd64
FlowTokenContract-4588µs ± 0%597µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ImperativeFib-420.9µs ± 0%21.7µs ± 0%~(p=1.000 n=1+1)
InterpretRecursionFib-42.06ms ± 0%2.17ms ± 0%~(p=1.000 n=1+1)
NewInterpreter/new_interpreter-4860ns ± 0%847ns ± 0%~(p=1.000 n=1+1)
NewInterpreter/new_sub-interpreter-4338ns ± 0%322ns ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/sema goos:linux goarch:amd64
QualifiedIdentifierCreation/One_level-42.54ns ± 0%2.49ns ± 0%~(p=1.000 n=1+1)
QualifiedIdentifierCreation/Three_levels-484.3ns ± 0%80.7ns ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
RuntimeFungibleTokenTransferInterpreter-4607µs ± 0%599µs ± 0%~(p=1.000 n=1+1)
RuntimeFungibleTokenTransferVM-4644µs ± 0%651µs ± 0%~(p=1.000 n=1+1)
RuntimeResourceDictionaryValues-42.77ms ± 0%2.86ms ± 0%~(p=1.000 n=1+1)
RuntimeResourceTracking-412.8ms ± 0%12.3ms ± 0%~(p=1.000 n=1+1)
RuntimeScriptNoop-415.5µs ± 0%15.2µs ± 0%~(p=1.000 n=1+1)
RuntimeVMInvokeContractImperativeFib-428.6µs ± 0%29.0µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/sema goos:linux goarch:amd64
SuperTypeInference/arrays-4222ns ± 0%229ns ± 0%~(p=1.000 n=1+1)
SuperTypeInference/composites-494.4ns ± 0%105.2ns ± 0%~(p=1.000 n=1+1)
SuperTypeInference/integers-4330ns ± 0%317ns ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ValueIsSubtypeOfSemaType-460.1ns ± 0%62.5ns ± 0%~(p=1.000 n=1+1)
 
alloc/opdelta
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ContractFunctionInvocation-4152kB ± 0%152kB ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
Emit-41.47MB ± 0%1.46MB ± 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/sema goos:linux goarch:amd64
FlowTokenContract-4215kB ± 0%215kB ± 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)
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/sema goos:linux goarch:amd64
QualifiedIdentifierCreation/One_level-40.00B 0.00B ~(all equal)
QualifiedIdentifierCreation/Three_levels-464.0B ± 0%64.0B ± 0%~(all equal)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
RuntimeFungibleTokenTransferInterpreter-4158kB ± 0%158kB ± 0%~(p=1.000 n=1+1)
RuntimeFungibleTokenTransferVM-4173kB ± 0%173kB ± 0%~(p=1.000 n=1+1)
RuntimeResourceDictionaryValues-41.76MB ± 0%1.77MB ± 0%~(p=1.000 n=1+1)
RuntimeResourceTracking-49.27MB ± 0%9.26MB ± 0%~(p=1.000 n=1+1)
RuntimeScriptNoop-48.01kB ± 0%7.99kB ± 0%~(p=1.000 n=1+1)
RuntimeVMInvokeContractImperativeFib-49.80kB ± 0%9.80kB ± 0%~(all equal)
pkg:github.com/onflow/cadence/sema goos:linux goarch:amd64
SuperTypeInference/arrays-472.0B ± 0%72.0B ± 0%~(all equal)
SuperTypeInference/composites-40.00B 0.00B ~(all equal)
SuperTypeInference/integers-40.00B 0.00B ~(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.46k ± 0%2.46k ± 0%~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
Emit-439.0k ± 0%39.0k ± 0%~(p=1.000 n=1+1)
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/sema goos:linux goarch:amd64
FlowTokenContract-43.47k ± 0%3.47k ± 0%~(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/sema goos:linux goarch:amd64
QualifiedIdentifierCreation/One_level-40.00 0.00 ~(all equal)
QualifiedIdentifierCreation/Three_levels-42.00 ± 0%2.00 ± 0%~(all equal)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
RuntimeFungibleTokenTransferInterpreter-42.98k ± 0%2.98k ± 0%~(all equal)
RuntimeFungibleTokenTransferVM-43.04k ± 0%3.04k ± 0%~(all equal)
RuntimeResourceDictionaryValues-436.7k ± 0%36.7k ± 0%~(p=1.000 n=1+1)
RuntimeResourceTracking-4159k ± 0%159k ± 0%~(p=1.000 n=1+1)
RuntimeScriptNoop-4113 ± 0%113 ± 0%~(all equal)
RuntimeVMInvokeContractImperativeFib-4197 ± 0%197 ± 0%~(all equal)
pkg:github.com/onflow/cadence/sema goos:linux goarch:amd64
SuperTypeInference/arrays-43.00 ± 0%3.00 ± 0%~(all equal)
SuperTypeInference/composites-40.00 0.00 ~(all equal)
SuperTypeInference/integers-40.00 0.00 ~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ValueIsSubtypeOfSemaType-41.00 ± 0%1.00 ± 0%~(all equal)
 

@turbolent
Copy link
Member

Replaced by #4400

@turbolent turbolent closed this Jan 5, 2026
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.

3 participants