From f6b1917fd6ed87ccb44c714483b6384b12e4eb11 Mon Sep 17 00:00:00 2001 From: TobiasWienand <104697364+TobiasWienand@users.noreply.github.com> Date: Mon, 11 Nov 2024 10:08:38 +0100 Subject: [PATCH] Fixes Switch Break Bug (#460) Bug can be seen when trying to compile Tests/FuzzilliTests/CompilerTests/switch_statements.js, which fails because "break statement outside of loop or switch", even though it isn't. This happens because breaks are expected in the switch cases, rather than the switch block. --- Sources/Fuzzilli/Compiler/Compiler.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Fuzzilli/Compiler/Compiler.swift b/Sources/Fuzzilli/Compiler/Compiler.swift index e9f9bbd2f..9e6020a41 100644 --- a/Sources/Fuzzilli/Compiler/Compiler.swift +++ b/Sources/Fuzzilli/Compiler/Compiler.swift @@ -448,7 +448,7 @@ public class JavaScriptCompiler { // (switch blocks don't propagate an outer .loop context) so we just need to check for .loop here if contextAnalyzer.context.contains(.loop){ emit(LoopBreak()) - } else if contextAnalyzer.context.contains(.switchBlock){ + } else if contextAnalyzer.context.contains(.switchCase) { emit(SwitchBreak()) } else { throw CompilerError.invalidNodeError("break statement outside of loop or switch")