Skip to content

Commit f33a9ba

Browse files
committed
Fix problem when using variable struct types in comprehensions
Fixes #901 on GitHub
1 parent 3f222d6 commit f33a9ba

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

changes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Bug fixes:
2222
with e.g. the ``--disable-warnings`` flag (:bugref:`893`).
2323
- Fix incorrect generation of par versions of functions referencing top-level
2424
tuples/records containing var fields (:bugref:`919`).
25+
- Fix problem where using an iterator of variable tuple or record types could
26+
result in a segfault (:bugref:`901`).
2527

2628
.. _v2.9.2:
2729

lib/typecheck.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2399,6 +2399,10 @@ class Typer {
23992399
KeepAlive c_in = c->in(i) != nullptr
24002400
? add_coercion(_env, _model, c->in(i), c, Expression::type(c->in(i)))
24012401
: nullptr;
2402+
auto* decl_ti = c->decl(i, j)->ti();
2403+
if (decl_ti->type().structBT() && decl_ti->domain() == nullptr) {
2404+
decl_ti->setStructDomain(_env, decl_ti->type());
2405+
}
24022406
if (!whereMap[c->decl(i, j)].empty()) {
24032407
// need a generator for all the decls up to this point
24042408
Expression* whereExpr = whereMap[c->decl(i, j)][0];
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/***
2+
!Test
3+
solvers: [gecode]
4+
expected: !Result
5+
- !Solution
6+
i: [0,0]
7+
j: [[0,0]]
8+
***/
9+
10+
array[1..2] of var 0..0: i;
11+
array[_] of var tuple(int, int): j ::output = [k | k in [if sum(i) > 1 then (0, 0) else (0, 0) endif]];

0 commit comments

Comments
 (0)