Skip to content

Commit 454a6ed

Browse files
committed
Merge remote-tracking branch 'origin/dmd-rewrite-stable' into merge_stable
2 parents d562736 + 8b0bdc3 commit 454a6ed

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

dmd/dtemplate.d

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1714,7 +1714,9 @@ MATCH deduceType(RootObject o, Scope* sc, Type tparam, ref TemplateParameters pa
17141714
edim = s ? getValue(s) : getValue(e);
17151715
}
17161716
}
1717-
if (tp && tp.matchArg(sc, t.dim, i, &parameters, dedtypes, null) || edim && edim.toInteger() == t.dim.toInteger())
1717+
if ((tp && tp.matchArg(sc, t.dim, i, &parameters, dedtypes, null)) ||
1718+
(edim && edim.isIntegerExp() && edim.toInteger() == t.dim.toInteger())
1719+
)
17181720
{
17191721
result = deduceType(t.next, sc, tparam.nextOf(), parameters, dedtypes, wm);
17201722
return;

dmd/expression.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ extern (C++) /* IN_LLVM abstract */ class Expression : ASTNode
475475
dinteger_t toInteger()
476476
{
477477
//printf("Expression %s\n", EXPtoString(op).ptr);
478-
if (!type.isTypeError())
478+
if (!type || !type.isTypeError())
479479
error(loc, "integer constant expression expected instead of `%s`", toChars());
480480
return 0;
481481
}

tests/dmd/runnable/ifti.d

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,20 @@ class Tst(TST, int v = 2) {
7272

7373
class Y : Tst!(float) {}
7474

75+
// https://issues.dlang.org/show_bug.cgi?id=24731
76+
void test24731()
77+
{
78+
static int solve(size_t N)(ref double[N+1][N])
79+
{
80+
return N;
81+
}
82+
83+
double[3][2] m;
84+
assert(solve(m) == 2);
85+
assert(solve!2(m) == 2);
86+
}
87+
88+
7589
void main() {
7690
Tst!(int) t = new Tst!(int);
7791
Y u = new Y;
@@ -113,4 +127,5 @@ void main() {
113127
printf("%g\n", i);
114128
}
115129

130+
test24731();
116131
}

0 commit comments

Comments
 (0)