Skip to content

Commit 1769bdf

Browse files
Name the outer dimension and give the 2-D test case its own method
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 65cc763 commit 1769bdf

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

‎liquidjava-example/src/main/java/testSuite/CorrectStringArrayLength.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ public static void initializers() {
2626
sized(new String[] { "a", "b" }, 2);
2727
String[] none = {};
2828
sized(none, 0);
29+
}
30+
31+
public static void dimensions() {
2932
rows(new String[2][3], 2);
3033
}
3134
}

‎liquidjava-verifier/src/main/java/liquidjava/processor/refinement_checker/RefinementTypeChecker.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,15 +262,15 @@ public <T> void visitCtNewArray(CtNewArray<T> newArray) {
262262
return;
263263
}
264264
// the length is the first dimension: inner arrays are not modelled, nothing is known about their lengths
265-
CtExpression<Integer> exp = l.get(0);
266-
Predicate c = getExpressionRefinements(exp);
265+
CtExpression<Integer> outerDimension = l.get(0);
266+
Predicate c = getExpressionRefinements(outerDimension);
267267
String name = GeneratedNames.of(GeneratedNames.ARRAY_LENGTH, context.getCounter());
268268
if (c.getVariableNames().contains(Keys.WILDCARD)) {
269269
c = c.substituteVariable(Keys.WILDCARD, name);
270270
} else {
271271
c = Predicate.createEquals(Predicate.createVar(name), c);
272272
}
273-
context.addVarToContext(name, factory.Type().INTEGER_PRIMITIVE, c, exp);
273+
context.addVarToContext(name, factory.Type().INTEGER_PRIMITIVE, c, outerDimension);
274274
newArray.putMetadata(Keys.REFINEMENT, Predicate
275275
.createEquals(BuiltinFunctionPredicate.length(Keys.WILDCARD, newArray), Predicate.createVar(name)));
276276
}

0 commit comments

Comments
 (0)