@@ -131,10 +131,11 @@ Compiler::StaticType LLVMTypeAnalyzer::variableTypeAfterBranch(Variable *var, LL
131131
132132 // Process the branch from end
133133 bool write = false ; // only used internally (the compiler doesn't need this)
134- return variableTypeAfterBranchFromEnd (var, ins , previousType, write, visitedInstructions);
134+ return typeAfterBranchFromEnd (var, end , previousType, write, visitedInstructions);
135135}
136136
137- Compiler::StaticType LLVMTypeAnalyzer::variableTypeAfterBranchFromEnd (Variable *var, LLVMInstruction *end, Compiler::StaticType previousType, bool &write, InstructionSet &visitedInstructions) const
137+ Compiler::StaticType
138+ LLVMTypeAnalyzer::typeAfterBranchFromEnd (std::variant<Variable *, List *> varOrList, LLVMInstruction *end, Compiler::StaticType previousType, bool &write, InstructionSet &visitedInstructions) const
138139{
139140 // Find the last write instruction
140141 LLVMInstruction *ins = end->previous ;
@@ -143,7 +144,7 @@ Compiler::StaticType LLVMTypeAnalyzer::variableTypeAfterBranchFromEnd(Variable *
143144 while (ins && !isLoopStart (ins) && !isIfStart (ins)) {
144145 if (isLoopEnd (ins) || isIfEnd (ins) || isElse (ins)) {
145146 // Process the nested loop or if statement
146- Compiler::StaticType ret = variableTypeAfterBranchFromEnd (var , ins, previousType, write, visitedInstructions);
147+ Compiler::StaticType ret = typeAfterBranchFromEnd (varOrList , ins, previousType, write, visitedInstructions);
147148
148149 if (typesMatch (ret, previousType)) {
149150 if (write)
@@ -155,7 +156,7 @@ Compiler::StaticType LLVMTypeAnalyzer::variableTypeAfterBranchFromEnd(Variable *
155156
156157 if (isElse (ins)) {
157158 // Process if branch (the else branch is already processed)
158- ret = variableTypeAfterBranchFromEnd (var , ins, previousType, write, visitedInstructions);
159+ ret = typeAfterBranchFromEnd (varOrList , ins, previousType, write, visitedInstructions);
159160
160161 if (typesMatch (ret, previousType)) {
161162 if (write) {
@@ -169,7 +170,7 @@ Compiler::StaticType LLVMTypeAnalyzer::variableTypeAfterBranchFromEnd(Variable *
169170
170171 ins = skipBranch (ins);
171172 }
172- } else if (isVariableWrite (ins, var ) && !isWriteNoOp (ins)) {
173+ } else if (std::holds_alternative<Variable *>(varOrList), isVariableWrite (ins, std::get<Variable *>(varOrList) ) && !isWriteNoOp (ins)) {
173174 // Variable write instruction
174175 Compiler::StaticType writeType = writeValueType (ins, visitedInstructions);
175176 write = true ;
0 commit comments