Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions compiler/src/dmd/expressionsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -12042,6 +12042,15 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
__equals = new DotIdExp(exp.loc, __equals, Id.object);
__equals = new DotIdExp(exp.loc, __equals, id);

/* https://issues.dlang.org/show_bug.cgi?id=23674
*
* Optimize before creating the call expression to the
* druntime hook as the optimizer may output errors
* that will get swallowed otherwise.
*/
exp.e1 = exp.e1.optimize(WANTvalue);
exp.e2 = exp.e2.optimize(WANTvalue);

auto arguments = new Expressions(2);
(*arguments)[0] = exp.e1;
(*arguments)[1] = exp.e2;
Expand Down
15 changes: 15 additions & 0 deletions compiler/test/fail_compilation/test23674.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// https://issues.dlang.org/show_bug.cgi?id=23674

/*
TEST_OUTPUT:
---
fail_compilation/test23674.d(14): Error: array index 2 is out of bounds `arr[0 .. 2]`
fail_compilation/test23674.d(14): Error: array index 3 is out of bounds `arr[0 .. 2]`
---
*/

void main()
{
string[2] arr;
assert(arr[2] == arr[3]);
}