File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
Sources/Fuzzilli/Compiler Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -431,9 +431,12 @@ public class JavaScriptCompiler {
431431 emit ( EndForInLoop ( ) )
432432
433433 case . identifier( let identifier) :
434- guard let loopVar = lookupIdentifier ( identifier. name) else {
435- // TODO instead of throwing an error, we should create a global property with the identifier name
436- throw CompilerError . unsupportedFeatureError ( " Identifier ' \( identifier. name) ' not found for for-in loop. " )
434+ let loopVar : Variable
435+ if let existingVar = lookupIdentifier ( identifier. name) {
436+ loopVar = existingVar
437+ } else {
438+ loopVar = emit ( LoadNamedVariable ( identifier. name) ) . output
439+ map ( identifier. name, to: loopVar)
437440 }
438441 emit ( BeginForInLoopWithReassignment ( ) , withInputs: [ obj, loopVar] )
439442 try enterNewScope {
@@ -459,9 +462,12 @@ public class JavaScriptCompiler {
459462 emit ( EndForOfLoop ( ) )
460463
461464 case . identifier( let identifier) :
462- guard let loopVar = lookupIdentifier ( identifier. name) else {
463- // TODO instead of throwing an error, we should create a global property with the identifier name
464- throw CompilerError . unsupportedFeatureError ( " Identifier ' \( identifier. name) ' not found for for-of loop. " )
465+ let loopVar : Variable
466+ if let existingVar = lookupIdentifier ( identifier. name) {
467+ loopVar = existingVar
468+ } else {
469+ loopVar = emit ( LoadNamedVariable ( identifier. name) ) . output
470+ map ( identifier. name, to: loopVar)
465471 }
466472 emit ( BeginForOfLoopWithReassignment ( ) , withInputs: [ obj, loopVar] )
467473 try enterNewScope {
You can’t perform that action at this time.
0 commit comments