@Override public PType caseAFieldNumberExp(AFieldNumberExp node, TypeCheckInfo question) throws AnalysisException { PExp tuple = node.getTuple(); question.qualifiers = null; PType type = tuple.apply(THIS, question.newConstraint(null)); node.setType(type); if (!question.assistantFactory.createPTypeAssistant().isProduct(type)) { TypeCheckerErrors.report(3094, "Field '#" + node.getField() + "' applied to non-tuple type", tuple.getLocation(), tuple); node.setType(AstFactory.newAUnknownType(node.getLocation())); return node.getType(); } AProductType product = question.assistantFactory.createPTypeAssistant().getProduct(type); long fn = node.getField().getValue(); if (fn > product.getTypes().size() || fn < 1) { TypeCheckerErrors.report(3095, "Field number does not match tuple size", node.getField().getLocation(), node.getField()); node.setType(AstFactory.newAUnknownType(node.getLocation())); return node.getType(); } node.setType(product.getTypes().get((int) fn - 1)); return node.getType(); }