Bug 21667 – scope parameter causes 'no size because of forward references'
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-02-27T22:05:12Z
Last change time
2023-04-17T09:59:52Z
Keywords
pull, rejects-valid
Assigned to
No Owner
Creator
Dennis
Comments
Comment #0 by dkorpel — 2021-02-27T22:05:12Z
I changed a parameter to have the `scope` storage class, and suddenly got an error that didn't follow from the change: "no size because of forward references". Test case:
```
struct M
{
F.Type f;
}
struct F
{
enum Type {a}
void foo(scope M m) {}
}
```
Without the `scope`, it compiles. I think the problem is that `scope` makes the compiler check whether type M has pointers, calling `determineFields` on M, which fails because it wants semantic analysis of F to be done for F.Type.
Comment #1 by pro.mathias.lang — 2021-06-16T06:02:25Z
*** Issue 20814 has been marked as a duplicate of this issue. ***
Comment #2 by pro.mathias.lang — 2021-06-16T06:02:45Z
It also triggers if the parameter is `scope ref`, see the duplicated issue.
Comment #3 by snarwin+bugzilla — 2021-09-06T14:50:02Z
Reduced example:
---
struct Foo
{
void delegate(scope Foo) dg;
}
---
Also triggers with `scope ref`, as per Mathias's comment.
Comment #4 by dlang-bot — 2022-10-14T16:19:40Z
@dkorpel created dlang/dmd pull request #14561 "Fix 21667 - scope parameter causes 'no size because of forward refere…" fixing this issue:
- Fix 21667 - scope parameter causes 'no size because of forward references'
https://github.com/dlang/dmd/pull/14561
Comment #5 by dlang-bot — 2023-04-17T09:59:52Z
dlang/dmd pull request #14561 "Fix 21667 - scope parameter causes 'no size because of forward refere…" was merged into master:
- f627c2f8db04ebd02a101f98867b66141af8b2db by Dennis Korpel:
Fix 21667 - scope parameter causes 'no size because of forward references'
https://github.com/dlang/dmd/pull/14561