@@ -896,6 +896,47 @@ TEST_F(LLVMCodeAnalyzer_VariableTypeAnalysis, WriteInLoop)
896896 ASSERT_EQ (setVar->targetType , Compiler::StaticType::Unknown);
897897}
898898
899+ TEST_F (LLVMCodeAnalyzer_VariableTypeAnalysis, NestedIfStatements)
900+ {
901+ LLVMInstructionList list;
902+ Variable var (" " , " " );
903+
904+ auto outerIf = std::make_shared<LLVMInstruction>(LLVMInstruction::Type::BeginIf, false );
905+ list.addInstruction (outerIf);
906+
907+ auto setVar1 = std::make_shared<LLVMInstruction>(LLVMInstruction::Type::WriteVariable, false );
908+ LLVMConstantRegister value1 (Compiler::StaticType::Number, 1 );
909+ setVar1->targetVariable = &var;
910+ setVar1->args .push_back ({ Compiler::StaticType::Unknown, &value1 });
911+ list.addInstruction (setVar1);
912+
913+ auto outerElse = std::make_shared<LLVMInstruction>(LLVMInstruction::Type::BeginElse, false );
914+ list.addInstruction (outerElse);
915+
916+ auto innerIf = std::make_shared<LLVMInstruction>(LLVMInstruction::Type::BeginIf, false );
917+ list.addInstruction (innerIf);
918+
919+ auto innerElse = std::make_shared<LLVMInstruction>(LLVMInstruction::Type::BeginElse, false );
920+ list.addInstruction (innerElse);
921+
922+ auto innerIfEnd = std::make_shared<LLVMInstruction>(LLVMInstruction::Type::EndIf, false );
923+ list.addInstruction (innerIfEnd);
924+
925+ auto setVar2 = std::make_shared<LLVMInstruction>(LLVMInstruction::Type::WriteVariable, false );
926+ LLVMConstantRegister value2 (Compiler::StaticType::String, " test" );
927+ setVar2->targetVariable = &var;
928+ setVar2->args .push_back ({ Compiler::StaticType::Unknown, &value2 });
929+ list.addInstruction (setVar2);
930+
931+ auto outerIfEnd = std::make_shared<LLVMInstruction>(LLVMInstruction::Type::EndIf, false );
932+ list.addInstruction (outerIfEnd);
933+
934+ m_analyzer->analyzeScript (list);
935+
936+ ASSERT_EQ (setVar1->targetType , Compiler::StaticType::Unknown);
937+ ASSERT_EQ (setVar2->targetType , Compiler::StaticType::Unknown);
938+ }
939+
899940TEST_F (LLVMCodeAnalyzer_VariableTypeAnalysis, ComplexNestedControlFlow)
900941{
901942 LLVMInstructionList list;
0 commit comments