Skip to content

[Compiler] Fix continue statement inside a switch-case#4509

Merged
SupunS merged 1 commit into
masterfrom
supun/fix-continue
Jun 24, 2026
Merged

[Compiler] Fix continue statement inside a switch-case#4509
SupunS merged 1 commit into
masterfrom
supun/fix-continue

Conversation

@SupunS

@SupunS SupunS commented Jun 23, 2026

Copy link
Copy Markdown
Member

Work towards #3804

Description

Currently the compiler crashes when trying to compile a continue statement nested inside a switch statement that is also inside a loop.


  • 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 Jun 23, 2026
@SupunS SupunS added the Bugfix label Jun 23, 2026
@github-actions

Copy link
Copy Markdown

Dependency Review

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

Scanned Files

None

@github-actions

Copy link
Copy Markdown

Benchstat comparison

  • Base branch: onflow:master
  • Base commit: 38729bf
Results

old.txtnew.txt
time/opdelta
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ByteArrayTransfer-41.12µs ± 0%1.15µs ± 0%~(p=1.000 n=1+1)
ByteArrayValueToByteSlice-481.0ns ± 0%81.1ns ± 0%~(p=1.000 n=1+1)
ByteSliceToByteArrayValue-4900ns ± 0%882ns ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/bbq/compiler goos:linux goarch:amd64
CompileFungibleTokenTransferTransaction-4134µs ± 0%137µs ± 0%~(p=1.000 n=1+1)
CompileTime-438.4µs ± 0%38.7µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ContractFunctionInvocation-4391µs ± 0%390µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
ContractImport-4229µs ± 0%236µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
EMVAddressTransfer-43.37µs ± 0%3.50µs ± 0%~(p=1.000 n=1+1)
Emit-44.67ms ± 0%4.71ms ± 0%~(p=1.000 n=1+1)
EnumTransfer-41.30µs ± 0%1.30µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ExportType/composite_type-4228ns ± 0%233ns ± 0%~(p=1.000 n=1+1)
ExportType/simple_type-443.4ns ± 0%43.4ns ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
FTTransfer-4167µs ± 0%168µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ImperativeFib-423.2µs ± 0%23.2µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
ImperativeFib-428.8µs ± 0%28.8µs ± 0%~(p=1.000 n=1+1)
ImperativeFibNewCompilerNewVM-455.1µs ± 0%55.9µs ± 0%~(p=1.000 n=1+1)
ImperativeFibNewVM-432.0µs ± 0%32.5µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
InterpretRecursionFib-42.35ms ± 0%2.48ms ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
InterpreterFTTransfer-4141µs ± 0%141µs ± 0%~(p=1.000 n=1+1)
InterpreterImperativeFib-424.3µs ± 0%24.5µs ± 0%~(p=1.000 n=1+1)
InterpreterNewStruct-468.1µs ± 0%68.3µs ± 0%~(p=1.000 n=1+1)
MethodCall/concrete_type_method_call-447.0µs ± 0%46.7µs ± 0%~(p=1.000 n=1+1)
MethodCall/interface_method_call-466.2µs ± 0%65.5µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
NewInterpreter/new_interpreter-4901ns ± 0%893ns ± 0%~(p=1.000 n=1+1)
NewInterpreter/new_sub-interpreter-4336ns ± 0%338ns ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
NewStruct-446.4µs ± 0%48.7µs ± 0%~(p=1.000 n=1+1)
NewStructRaw-42.90µs ± 0%3.01µs ± 0%~(p=1.000 n=1+1)
RecursionFib-41.74ms ± 0%1.79ms ± 0%~(p=1.000 n=1+1)
RuntimeFungibleTokenTransfer-4783µs ± 0%794µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
RuntimeFungibleTokenTransferInterpreter-4638µs ± 0%651µs ± 0%~(p=1.000 n=1+1)
RuntimeResourceDictionaryValues-42.80ms ± 0%2.81ms ± 0%~(p=1.000 n=1+1)
RuntimeResourceTracking-49.83ms ± 0%9.68ms ± 0%~(p=1.000 n=1+1)
RuntimeScriptNoop-414.8µs ± 0%14.6µs ± 0%~(p=1.000 n=1+1)
RuntimeVMInvokeContractImperativeFib-445.0µs ± 0%45.7µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ValueIsSubtypeOfSemaType-458.8ns ± 0%59.3ns ± 0%~(p=1.000 n=1+1)
 
alloc/opdelta
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ByteArrayTransfer-41.08kB ± 0%1.08kB ± 0%~(p=1.000 n=1+1)
ByteArrayValueToByteSlice-432.0B ± 0%32.0B ± 0%~(all equal)
ByteSliceToByteArrayValue-4841B ± 0%839B ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/bbq/compiler goos:linux goarch:amd64
CompileFungibleTokenTransferTransaction-482.9kB ± 0%82.9kB ± 0%~(all equal)
CompileTime-417.0kB ± 0%17.0kB ± 0%~(all equal)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ContractFunctionInvocation-4145kB ± 0%145kB ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
ContractImport-477.8kB ± 0%77.5kB ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
EMVAddressTransfer-42.45kB ± 0%2.45kB ± 0%~(all equal)
Emit-41.52MB ± 0%1.52MB ± 0%~(p=1.000 n=1+1)
EnumTransfer-4896B ± 0%897B ± 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.8kB ± 0%46.8kB ± 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-426.7kB ± 0%26.7kB ± 0%~(all equal)
ImperativeFibNewVM-49.00kB ± 0%9.00kB ± 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-447.1kB ± 0%47.1kB ± 0%~(p=1.000 n=1+1)
InterpreterImperativeFib-48.29kB ± 0%8.29kB ± 0%~(all equal)
InterpreterNewStruct-424.6kB ± 0%24.8kB ± 0%~(p=1.000 n=1+1)
MethodCall/concrete_type_method_call-411.1kB ± 0%11.1kB ± 0%~(p=1.000 n=1+1)
MethodCall/interface_method_call-418.0kB ± 0%18.0kB ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
NewInterpreter/new_interpreter-4976B ± 0%976B ± 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.0kB ± 0%14.1kB ± 0%~(p=1.000 n=1+1)
NewStructRaw-41.75kB ± 0%1.70kB ± 0%~(p=1.000 n=1+1)
RecursionFib-4342kB ± 0%342kB ± 0%~(all equal)
RuntimeFungibleTokenTransfer-4250kB ± 0%251kB ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
RuntimeFungibleTokenTransferInterpreter-4173kB ± 0%173kB ± 0%~(p=1.000 n=1+1)
RuntimeResourceDictionaryValues-41.78MB ± 0%1.78MB ± 0%~(p=1.000 n=1+1)
RuntimeResourceTracking-46.98MB ± 0%6.98MB ± 0%~(p=1.000 n=1+1)
RuntimeScriptNoop-48.06kB ± 0%8.06kB ± 0%~(p=1.000 n=1+1)
RuntimeVMInvokeContractImperativeFib-414.3kB ± 0%14.3kB ± 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-47.00 ± 0%7.00 ± 0%~(all equal)
ByteArrayValueToByteSlice-41.00 ± 0%1.00 ± 0%~(all equal)
ByteSliceToByteArrayValue-45.00 ± 0%5.00 ± 0%~(all equal)
pkg:github.com/onflow/cadence/bbq/compiler goos:linux goarch:amd64
CompileFungibleTokenTransferTransaction-4569 ± 0%569 ± 0%~(all equal)
CompileTime-4207 ± 0%207 ± 0%~(all equal)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ContractFunctionInvocation-42.23k ± 0%2.23k ± 0%~(all equal)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
ContractImport-41.37k ± 0%1.37k ± 0%~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
EMVAddressTransfer-429.0 ± 0%29.0 ± 0%~(all equal)
Emit-441.0k ± 0%41.0k ± 0%~(all equal)
EnumTransfer-413.0 ± 0%13.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.50k ± 0%1.50k ± 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-4528 ± 0%528 ± 0%~(all equal)
ImperativeFibNewVM-4364 ± 0%364 ± 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.04k ± 0%1.04k ± 0%~(all equal)
InterpreterImperativeFib-4175 ± 0%175 ± 0%~(all equal)
InterpreterNewStruct-4408 ± 0%408 ± 0%~(all equal)
MethodCall/concrete_type_method_call-4402 ± 0%402 ± 0%~(all equal)
MethodCall/interface_method_call-4512 ± 0%512 ± 0%~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
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/bbq/vm/test goos:linux goarch:amd64
NewStruct-4422 ± 0%422 ± 0%~(all equal)
NewStructRaw-430.0 ± 0%30.0 ± 0%~(all equal)
RecursionFib-419.5k ± 0%19.5k ± 0%~(all equal)
RuntimeFungibleTokenTransfer-44.21k ± 0%4.21k ± 0%~(all equal)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
RuntimeFungibleTokenTransferInterpreter-43.21k ± 0%3.21k ± 0%~(all equal)
RuntimeResourceDictionaryValues-436.7k ± 0%36.7k ± 0%~(all equal)
RuntimeResourceTracking-4128k ± 0%128k ± 0%~(p=1.000 n=1+1)
RuntimeScriptNoop-4113 ± 0%113 ± 0%~(all equal)
RuntimeVMInvokeContractImperativeFib-4481 ± 0%481 ± 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 June 24, 2026 14:19
@SupunS SupunS requested a review from turbolent as a code owner June 24, 2026 14:19

@turbolent turbolent left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good catch!

Comment thread bbq/compiler/compiler.go
@SupunS SupunS merged commit fcc94ce into master Jun 24, 2026
15 of 17 checks passed
@SupunS SupunS deleted the supun/fix-continue branch June 24, 2026 19:23
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