Skip to content

Commit

Permalink
Coerce comprehension expression to var int in case of sets. Currently…
Browse files Browse the repository at this point in the history
… this at least triggers an error message rather than crashing, but it will work as soon as var set comprehensions are supported. Fixes #135.
  • Loading branch information
guidotack committed Feb 1, 2017
1 parent ea159ec commit bdc96a7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/minizinc/ast.hh
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,8 @@ namespace MiniZinc {
Expression* where(void) const { return _where; }
/// Return generator body
Expression* e(void) const { return _e; }
/// Set generator body
void e(Expression* e0) { _e = e0; }
/// Re-construct (used for copying)
void init(Expression* e, Generators& g);
};
Expand Down
4 changes: 4 additions & 0 deletions lib/typecheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,10 @@ namespace MiniZinc {
"set comprehension expression must be scalar, but is `"
+c.e()->type().toString(_env)+"'");
tt.st(Type::ST_SET);
if (tt.isvar()) {
c.e(addCoercion(_env, _model, c.e(), Type::varint())());
tt.bt(Type::BT_INT);
}
} else {
if (c.e()->type().dim() != 0)
throw TypeError(_env,c.e()->loc(),
Expand Down

0 comments on commit bdc96a7

Please sign in to comment.