Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d2a432421f |
No files matched your search
@@ -0,0 +1,19 @@
|
||||
import java.lang.Integer;
|
||||
import java.lang.System;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.io.PrintStream;
|
||||
|
||||
public class Bug458 {
|
||||
public static main(args) {
|
||||
List<Integer> l = new ArrayList<Integer>();
|
||||
l.add(1);
|
||||
l.add(2);
|
||||
Integer s = 0;
|
||||
for (Integer x : l) {
|
||||
if (x == 1) { continue; } // "break" is rejected as well
|
||||
s = s + x;
|
||||
}
|
||||
System.out.println(s); // Java: 1
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
import java.lang.Boolean;
|
||||
import java.lang.System;
|
||||
import java.io.PrintStream;
|
||||
|
||||
public class Bug463 {
|
||||
public static and(Boolean a, Boolean b) { return a & b; } // | and ^ behave the same
|
||||
public static or(Boolean a, Boolean b) { return a | b; }
|
||||
public static xor(Boolean a, Boolean b) { return a ^ b; }
|
||||
}
|
||||
@@ -1305,6 +1305,11 @@ public class Codegen {
|
||||
mv.visitMethodInsn(INVOKEINTERFACE, "java/lang/Iterable", "iterator", "()Ljava/util/Iterator;", true);
|
||||
var start = new Label();
|
||||
var end = new Label();
|
||||
|
||||
var env = new BreakEnv();
|
||||
env.startLabel = start;
|
||||
env.endLabel = end;
|
||||
|
||||
mv.visitLabel(start);
|
||||
mv.visitInsn(DUP);
|
||||
mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "hasNext", "()Z", true);
|
||||
@@ -1314,7 +1319,9 @@ public class Codegen {
|
||||
mv.visitTypeInsn(CHECKCAST, localVar.type().getInternalName());
|
||||
mv.visitVarInsn(ASTORE, localVar.index);
|
||||
|
||||
state.breakStack.push(env);
|
||||
generate(state, forEach.body());
|
||||
state.breakStack.pop();
|
||||
|
||||
mv.visitJumpInsn(GOTO, start);
|
||||
mv.visitLabel(end);
|
||||
|
||||
@@ -57,9 +57,4 @@ public record TargetFunNType(String name, List<TargetType> funNParams, List<Targ
|
||||
}
|
||||
return Objects.equals(name, otfn.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toSignature();
|
||||
}
|
||||
}
|
||||
@@ -357,17 +357,6 @@ public class TYPEStmt implements StatementVisitor {
|
||||
numericAdditionOrStringConcatenation.add(stringConcat);
|
||||
}
|
||||
}
|
||||
if (binary.operation.equals(BinaryExpr.Operator.AND) || binary.operation.equals(BinaryExpr.Operator.OR) || binary.operation.equals(BinaryExpr.Operator.XOR)) {
|
||||
// Binary operations defined on boolean
|
||||
if (classNames.contains(bool.getName())) {
|
||||
Constraint<Pair> boolOp = new Constraint<>();
|
||||
boolOp.add(new Pair(binary.lexpr.getType(), bool, PairOperator.EQUALSDOT, loc(binary.getOffset())));
|
||||
boolOp.add(new Pair(binary.rexpr.getType(), bool, PairOperator.EQUALSDOT, loc(binary.getOffset())));
|
||||
boolOp.add(new Pair(bool, binary.getType(), PairOperator.EQUALSDOT, loc(binary.getOffset())));
|
||||
numericAdditionOrStringConcatenation.add(boolOp);
|
||||
}
|
||||
}
|
||||
|
||||
if (numericAdditionOrStringConcatenation.isEmpty()) {
|
||||
throw new TypeinferenceException("Kein Typ für " + binary.operation.toString() + " vorhanden", binary.getOffset());
|
||||
}
|
||||
|
||||
@@ -50,9 +50,7 @@ public class Logger {
|
||||
public static void resetLogs() {
|
||||
defaultWriter = null;
|
||||
try {
|
||||
FileUtils.cleanDirectory(logFolder);
|
||||
} catch (FileNotFoundException e) {
|
||||
// Ignore
|
||||
FileUtils.cleanDirectory(logFolder);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -1808,27 +1808,10 @@ public class TestComplete {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBug463() throws Exception {
|
||||
var classFiles = generateClassFiles(createClassLoader(), "Bug463.jav");
|
||||
var clazz = classFiles.get("Bug463");
|
||||
var instance = clazz.getDeclaredConstructor().newInstance();
|
||||
|
||||
var and = clazz.getDeclaredMethod("and", Boolean.class, Boolean.class);
|
||||
assertEquals(true, and.invoke(instance, true, true));
|
||||
assertEquals(false, and.invoke(instance, true, false));
|
||||
assertEquals(false, and.invoke(instance, false, true));
|
||||
assertEquals(false, and.invoke(instance, false, false));
|
||||
|
||||
var or = clazz.getDeclaredMethod("or", Boolean.class, Boolean.class);
|
||||
assertEquals(true, or.invoke(instance, true, true));
|
||||
assertEquals(true, or.invoke(instance, true, false));
|
||||
assertEquals(true, or.invoke(instance, false, true));
|
||||
assertEquals(false, or.invoke(instance, false, false));
|
||||
|
||||
var xor = clazz.getDeclaredMethod("xor", Boolean.class, Boolean.class);
|
||||
assertEquals(false, xor.invoke(instance, true, true));
|
||||
assertEquals(true, xor.invoke(instance, true, false));
|
||||
assertEquals(true, xor.invoke(instance, false, true));
|
||||
assertEquals(false, xor.invoke(instance, false, false));
|
||||
public void testBug458() throws Exception {
|
||||
var classFiles = generateClassFiles(createClassLoader(), "Bug458.jav");
|
||||
var clazz = classFiles.get("Bug458");
|
||||
var main = clazz.getDeclaredMethod("main", List.class);
|
||||
main.invoke(null, List.of());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user