Skip to content

Commit

Permalink
Fix for #577
Browse files Browse the repository at this point in the history
This was a simple problem where the count component of an array
generator expression was not being checked as an int.
  • Loading branch information
DavePearce committed Jan 28, 2016
1 parent a227247 commit 8f4ac3b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions modules/wyc/src/wyc/builder/FlowTypeChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -1739,10 +1739,11 @@ private Expr propagate(Expr.ArrayInitialiser expr, Environment environment, Cont
return expr;
}

private Expr propagate(Expr.ArrayGenerator expr, Environment environment, Context context) {
private Expr propagate(Expr.ArrayGenerator expr, Environment environment, Context context) {
expr.element = propagate(expr.element, environment, context);
expr.count = propagate(expr.count, environment, context);
expr.count = propagate(expr.count, environment, context);
expr.type = Nominal.Array(expr.element.result(), true);
checkIsSubtype(Type.T_INT, expr.count);
return expr;
}

Expand Down
6 changes: 3 additions & 3 deletions tests/invalid/ListGenerator_Invalid_4.sysout
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
../../tests/invalid/ListGenerator_Invalid_4.whiley:0: operand types are not compatible (bool vs int)

^
../../tests/invalid/ListGenerator_Invalid_4.whiley:2: expected type int, found byte
return [0; n]
^

0 comments on commit 8f4ac3b

Please sign in to comment.