Bug 17576 – mixin template cannot define alias

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-06-30T00:20:12Z
Last change time
2024-12-13T18:52:56Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
Bolpat
Moved to GitHub: dmd#19271 →

Comments

Comment #0 by qs.il.paperinik — 2017-06-30T00:20:12Z
mixin template Test(alias f) { import std.traits : ReturnType; alias R = ReturnType!f; R foo() { } } struct S { void foo(int) { } mixin Test!foo T; alias foo = T.foo; } gives me the error message "template instance std.traits.ReturnType!(foo) is used as a type" However, when R foo() { } is replaced with ReturnType!f foo() { } the error message is "isCallable!(foo) is not an expression", and if one deletes the alias for R, the error disappears. Instead, if I precede the mixin template with "import std.traits : isCallable;" and constrain it with "if (isCallable!f)", the error is "no property 'foo' for type 'void'" essentially because it cannot instance isCallable!f for whatever reason. I suspect it is a bug in DMD. It could be in Phobos's ReturnType or isCallable.
Comment #1 by robert.schadek — 2024-12-13T18:52:56Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19271 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB