D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 22356 - Can't mixin the return type of a function
Summary: Can't mixin the return type of a function
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull, rejects-valid
Depends on:
Blocks:
 
Reported: 2021-10-04 14:57 UTC by Paul Backus
Modified: 2021-10-05 07:59 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Paul Backus 2021-10-04 14:57:34 UTC
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 Boris Carvajal 2021-10-04 15:29:07 UTC
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 Dlang Bot 2021-10-04 16:38:57 UTC
@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 Dlang Bot 2021-10-05 07:59:38 UTC
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