Bug 22356 – Can't mixin the return type of a function
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-10-04T14:57:34Z
Last change time
2021-10-05T07:59:38Z
Keywords
pull, rejects-valid
Assigned to
No Owner
Creator
Paul Backus
Comments
Comment #0 by snarwin+bugzilla — 2021-10-04T14:57:34Z
As of DMD 2.097.2, the following program fails to compile:
---
mixin("void") func_name() { /* ... */ }
---
The error message is:
---
bug.d(1): Error: found `func_name` when expecting `;`
bug.d(1): Error: declaration expected, not `(`
---
According to the language spec, any BasicType can be used as a function return type [1], and a MixinType can be used anywhere a BasicType is allowed [2], so the program should compile.
[1] https://dlang.org/spec/function.html#FuncDeclaration
[2] https://dlang.org/spec/type.html#BasicType
Comment #1 by boris2.9 — 2021-10-04T15:29:07Z
I forgot to report this long time ago.
This simple code didn't work.
mixin("int") x;
The error only happens at declaration level, it works with statements.
Comment #2 by dlang-bot — 2021-10-04T16:38:57Z
@BorisCarvajal created dlang/dmd pull request #13126 "Fix Issue 22356 - Can't mixin the return type of a function" fixing this issue:
- Fix Issue 22356 - Can't mixin the return type of a function
https://github.com/dlang/dmd/pull/13126
Comment #3 by dlang-bot — 2021-10-05T07:59:38Z
dlang/dmd pull request #13126 "Fix Issue 22356 - Can't mixin the return type of a function" was merged into master:
- b433c28b7cd9ef4a548faf356aee16407a69775a by Boris Carvajal:
Fix Issue 22356 - Can't mixin the return type of a function
https://github.com/dlang/dmd/pull/13126