Bug 21870 – Property/method not invoked and requires () when used in static array length
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-04-28T01:08:37Z
Last change time
2021-04-29T00:46:40Z
Keywords
diagnostic, pull, rejects-valid
Assigned to
No Owner
Creator
Vladimir Panteleev
Comments
Comment #0 by dlang-bugzilla — 2021-04-28T01:08:37Z
////////////////////////////// test.d /////////////////////////////
struct S
{
@property size_t count() const
{
return 1;
}
}
int[S.init.count()] x; // OK
int[S.init.count ] y; // error
// Error: need `this` for `count` of type `const @property ulong()`
///////////////////////////////////////////////////////////////////
Additionally, the error message is misleading. Older versions of compilers produced a better error:
2.079.0 to 2.087.1: Failure with output: test.d(9): Error: integer constant expression expected instead of `S().count`
Comment #1 by dlang-bot — 2021-04-28T08:31:54Z
@TungstenHeart created dlang/dmd pull request #12481 "fix 21870 - Property/method not invoked and requires () when used in static array length" fixing this issue:
- fix 21870 - Property/method not invoked and requires () when used in static array length
https://github.com/dlang/dmd/pull/12481
Comment #2 by dlang-bot — 2021-04-29T00:46:40Z
dlang/dmd pull request #12481 "fix 21870 - Property/method not invoked and requires () when used in static array length" was merged into master:
- 700a75c7179c1bc5fbbc89183961c3d8fd8e63a9 by Basile Burg:
fix 21870, 15478 - Property/method not invoked and requires () when used in static array length
https://github.com/dlang/dmd/pull/12481