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.
Comment #1 by slavo5150 — 2019-04-09T01:06:27Z
According to https://run.dlang.io/is/s54vvI this may be a regression introduced in 2.063.
Comment #2 by b2.temp — 2019-11-16T09:13:37Z
this even crashes the compiler now
Comment #3 by b2.temp — 2019-11-16T09:16:40Z
it's the program
Comment #4 by bugzilla — 2019-12-18T10:10:42Z
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