@@ -152,6 +152,36 @@ TEST(LLVMCodeAnalyzer_ListTypeAnalysis, StringOptimization_AfterClear)
152152 ASSERT_EQ (appendList2->targetType , Compiler::StaticType::Number);
153153}
154154
155+ TEST (LLVMCodeAnalyzer_ListTypeAnalysis, StringOptimization_AfterClear_DifferentString)
156+ {
157+ LLVMCodeAnalyzer analyzer;
158+ LLVMInstructionList list;
159+ List targetList (" " , " " );
160+
161+ auto clearList = std::make_shared<LLVMInstruction>(LLVMInstruction::Type::ClearList, false );
162+ clearList->targetList = &targetList;
163+ list.addInstruction (clearList);
164+
165+ auto appendList1 = std::make_shared<LLVMInstruction>(LLVMInstruction::Type::AppendToList, false );
166+ LLVMConstantRegister value1 (Compiler::StaticType::String, " 1.0" );
167+ appendList1->targetList = &targetList;
168+ appendList1->args .push_back ({ Compiler::StaticType::Unknown, &value1 });
169+ list.addInstruction (appendList1);
170+
171+ auto appendList2 = std::make_shared<LLVMInstruction>(LLVMInstruction::Type::AppendToList, false );
172+ LLVMConstantRegister value2 (Compiler::StaticType::Bool, true );
173+ appendList2->targetList = &targetList;
174+ appendList2->args .push_back ({ Compiler::StaticType::Unknown, &value2 });
175+ list.addInstruction (appendList2);
176+
177+ analyzer.analyzeScript (list);
178+
179+ ASSERT_EQ (appendList1->targetType , Compiler::StaticType::Void);
180+
181+ // String "1.0" does NOT get optimized to Number because it would convert to "1"
182+ ASSERT_EQ (appendList2->targetType , Compiler::StaticType::String);
183+ }
184+
155185TEST (LLVMCodeAnalyzer_ListTypeAnalysis, ClearListOperation)
156186{
157187 LLVMCodeAnalyzer analyzer;
0 commit comments