@@ -191,6 +191,41 @@ TEST(LLVMCodeAnalyzer_VariableTypeAnalysis, RepeatUntilLoop)
191191 ASSERT_EQ (setVar1->targetType , Compiler::StaticType::Number | Compiler::StaticType::Bool);
192192}
193193
194+ TEST (LLVMCodeAnalyzer_VariableTypeAnalysis, ProcedureCallInLoop)
195+ {
196+ LLVMCodeAnalyzer analyzer;
197+ LLVMInstructionList list;
198+ Variable var (" " , " " );
199+
200+ auto setVar1 = std::make_shared<LLVMInstruction>(LLVMInstruction::Type::WriteVariable, false );
201+ LLVMConstantRegister value1 (Compiler::StaticType::Number, 1.25 );
202+ setVar1->targetVariable = &var;
203+ setVar1->args .push_back ({ Compiler::StaticType::Unknown, &value1 });
204+ list.addInstruction (setVar1);
205+
206+ auto loopStart = std::make_shared<LLVMInstruction>(LLVMInstruction::Type::BeginRepeatLoop, false );
207+ list.addInstruction (loopStart);
208+
209+ auto setVar2 = std::make_shared<LLVMInstruction>(LLVMInstruction::Type::WriteVariable, false );
210+ LLVMConstantRegister value2 (Compiler::StaticType::Number, 5 );
211+ setVar2->targetVariable = &var;
212+ setVar2->args .push_back ({ Compiler::StaticType::Unknown, &value2 });
213+ list.addInstruction (setVar2);
214+
215+ auto procCall = std::make_shared<LLVMInstruction>(LLVMInstruction::Type::CallProcedure, false );
216+ list.addInstruction (procCall);
217+
218+ auto loopEnd = std::make_shared<LLVMInstruction>(LLVMInstruction::Type::EndLoop, false );
219+ list.addInstruction (loopEnd);
220+
221+ analyzer.analyzeScript (list);
222+
223+ ASSERT_EQ (setVar1->targetType , Compiler::StaticType::Unknown);
224+
225+ // Type unknown due to procedure call
226+ ASSERT_EQ (setVar2->targetType , Compiler::StaticType::Unknown);
227+ }
228+
194229TEST (LLVMCodeAnalyzer_VariableTypeAnalysis, LoopMultipleWrites_UnknownType)
195230{
196231 LLVMCodeAnalyzer analyzer;
0 commit comments