<commit_before>package net.sandius.rembulan.compiler.analysis;

import net.sandius.rembulan.compiler.IRFunc;
import net.sandius.rembulan.compiler.analysis.types.FunctionType;
import net.sandius.rembulan.compiler.analysis.types.LuaTypes;
import net.sandius.rembulan.compiler.analysis.types.ReturnType;
import net.sandius.rembulan.compiler.analysis.types.Type;
import net.sandius.rembulan.compiler.analysis.types.TypeSeq;
import net.sandius.rembulan.compiler.ir.*;
import net.sandius.rembulan.util.Check;

import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Queue;
import java.util.Set;

import static net.sandius.rembulan.compiler.analysis.StaticMathImplementation.MAY_BE_INTEGER;
import static net.sandius.rembulan.compiler.analysis.StaticMathImplementation.MUST_BE_FLOAT;
import static net.sandius.rembulan.compiler.analysis.StaticMathImplementation.MUST_BE_INTEGER;

class TyperVisitor extends CodeVisitor {

	private final Map<Val, Type> valTypes;
	private final Map<PhiVal, Type> phiValTypes;
	private final Map<MultiVal, TypeSeq> multiValTypes;
	private final Map<Label, VarState> varStates;

	private final Set<Var> allVars;
	private final Set<Var> reifiedVars;

	private final Queue<Label> open;

	private final Set<ReturnType> returnTypes;

	private boolean changed;
	private VarState currentVarState;

	public TyperVisitor() {
		this.valTypes = new HashMap<>();
		this.phiValTypes = new HashMap<>();
		this.multiValTypes = new HashMap<>();
		this.varStates = new HashMap<>();

		this.allVars = new HashSet<>();
		this.reifiedVars = new HashSet<>();

		this.open = new ArrayDeque<>();

		this.returnTypes = new HashSet<>();
	}

	public TypeInfo valTypes() {
		return TypeInfo.of(valTypes, phiValTypes, multiValTypes, allVars, reifiedVars, returnType());
	}

	private static TypeSeq returnTypeToTypeSeq(ReturnType rt) {
		if (rt instanceof ReturnType.ConcreteReturnType) {
			return ((ReturnType.ConcreteReturnType) rt).typeSeq;
		}
		else if (rt instanceof ReturnType.TailCallReturnType) {
			Type targetType = ((ReturnType.TailCallReturnType) rt).target;
			if (targetType instanceof FunctionType) {
				FunctionType ft = (FunctionType) targetType;
				return ft.returnTypes();
			}
			else {
				return TypeSeq.vararg();
			}
		}
		else {
			throw new IllegalStateException("unknown return type: " + rt.toString());
		}
	}
<commit_msg>Correcting the treatment of unknown return type objects.<commit_after>package net.sandius.rembulan.compiler.analysis;

import net.sandius.rembulan.compiler.IRFunc;
import net.sandius.rembulan.compiler.analysis.types.FunctionType;
import net.sandius.rembulan.compiler.analysis.types.LuaTypes;
import net.sandius.rembulan.compiler.analysis.types.ReturnType;
import net.sandius.rembulan.compiler.analysis.types.Type;
import net.sandius.rembulan.compiler.analysis.types.TypeSeq;
import net.sandius.rembulan.compiler.ir.*;
import net.sandius.rembulan.util.Check;

import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Queue;
import java.util.Set;

import static net.sandius.rembulan.compiler.analysis.StaticMathImplementation.MAY_BE_INTEGER;
import static net.sandius.rembulan.compiler.analysis.StaticMathImplementation.MUST_BE_FLOAT;
import static net.sandius.rembulan.compiler.analysis.StaticMathImplementation.MUST_BE_INTEGER;

class TyperVisitor extends CodeVisitor {

	private final Map<Val, Type> valTypes;
	private final Map<PhiVal, Type> phiValTypes;
	private final Map<MultiVal, TypeSeq> multiValTypes;
	private final Map<Label, VarState> varStates;

	private final Set<Var> allVars;
	private final Set<Var> reifiedVars;

	private final Queue<Label> open;

	private final Set<ReturnType> returnTypes;

	private boolean changed;
	private VarState currentVarState;

	public TyperVisitor() {
		this.valTypes = new HashMap<>();
		this.phiValTypes = new HashMap<>();
		this.multiValTypes = new HashMap<>();
		this.varStates = new HashMap<>();

		this.allVars = new HashSet<>();
		this.reifiedVars = new HashSet<>();

		this.open = new ArrayDeque<>();

		this.returnTypes = new HashSet<>();
	}

	public TypeInfo valTypes() {
		return TypeInfo.of(valTypes, phiValTypes, multiValTypes, allVars, reifiedVars, returnType());
	}

	private static TypeSeq returnTypeToTypeSeq(ReturnType rt) {
		if (rt instanceof ReturnType.ConcreteReturnType) {
			return ((ReturnType.ConcreteReturnType) rt).typeSeq;
		}
		else if (rt instanceof ReturnType.TailCallReturnType) {
			Type targetType = ((ReturnType.TailCallReturnType) rt).target;
			if (targetType instanceof FunctionType) {
				FunctionType ft = (FunctionType) targetType;
				return ft.returnTypes();
			}
			else {
				return TypeSeq.vararg();
			}
		}
		else {
			throw new IllegalArgumentException("Illegal return type: " + rt);
		}
	}

{'fraction_non_alphanumeric': 0.10820818761571693, 'fraction_numerical': 0.0, 'mean_word_length': 5.330729166666667, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2281584', 'n_tokens_mistral': 1634, 'n_tokens_neox': 1544, 'n_words': 331}