Bug 19476 – explicit mixin template function call results in recursive call instead
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-12-11T13:15:23Z
Last change time
2020-08-24T04:35:44Z
Keywords
pull
Assigned to
No Owner
Creator
Dennis
Comments
Comment #0 by dkorpel — 2018-12-11T13:15:23Z
Context at https://forum.dlang.org/post/[email protected]
Code:
```
mixin template operators() {
S opBinary(string op, T)(T rhs) {
return rhs;
}
}
struct S {
mixin operators ops;
S opBinary(string op, T)(T a) {
return ops.opBinary!op(a);
}
}
void main() {
S.init.opBinary!"+"(S.init);
}
```
Expected:
The call `ops.opBinary` to refer to the mixin template.
Actual:
A recursive call is made resulting in stack overflow.
When doing `alias opBinary = ops.opBinary` before the call it does work correctly.
A somewhat simpler example:
mixin template operators() {
int foo(int op = 1, T)(T rhs) {
return 1;
}
}
struct S {
mixin operators ops;
int foo(int op = 1, T)(T a) {
return ops.foo!1(a);
}
}
void main() {
S.init.foo(S.init);
}
Comment #5 by moonlightsentinel — 2020-06-05T13:37:11Z
Digger:
commit b10683946e47b9f5f03270047a7dfa18d28fd58d
Author: Walter Bright <[email protected]>
Date: Mon May 6 00:39:32 2013 -0700
dmd: Merge pull request #1930 from 9rnsr/new_ufcs
https://github.com/dlang/dmd/pull/1930
Implement proper UFCS name look up
Comment #6 by dlang-bot — 2020-08-23T19:36:14Z
@BorisCarvajal created dlang/dmd pull request #11611 "Fix Issue 19476 - explicit mixin template function call results in re…" fixing this issue:
- Fix Issue 19476 - explicit mixin template function call results in recursive call instead
https://github.com/dlang/dmd/pull/11611
Comment #7 by dlang-bot — 2020-08-24T04:35:44Z
dlang/dmd pull request #11611 "Fix Issue 19476 - explicit mixin template function call results in re…" was merged into stable:
- 18cb9fd23f369376b911a2caf3152744d93a3350 by Boris Carvajal:
Fix Issue 19476 - explicit mixin template function call results in recursive call instead
https://github.com/dlang/dmd/pull/11611