Bug 17235 – Compile error inout member function, out-of-order semantic
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-02-28T21:58:09Z
Last change time
2023-05-18T12:14:33Z
Keywords
industry
Assigned to
No Owner
Creator
Johan Engelen
Comments
Comment #0 by jbc.engelen — 2017-02-28T21:58:09Z
This bug concerns a compilation case where compilation of one file results in `semantic2` of a templated struct's member function, before `semantic` is performed. The bug happens because compilation of the second file requires `semantic` to be performed, which is exited early because `semantic2` already ran.
The cmdline:
`dmd tracing.d defines.d`
subtyping.d(17): Error: variable subtyping.Str!().Str.foo.this inout variables can only be declared inside inout functions
The files:
```
// File: defines.d
import subtyping;
Str!() slotsState;
```
```
// File: subtyping.d
import tracing;
int info(T)()
{
calcSize!T;
return 0;
}
struct Str()
{
alias S = Tis!int;
void foo() inout
{
}
}
struct Tis(V)
{
static someInfo = info!Tis;
V arr;
}
```
```
// File: tracing.d
import subtyping;
template retFalse(T)
{
import subtyping;
enum retFalse = false;
}
size_t staticCalcSizeSL(T)()
{
return retFalse!T;
}
void calcSize(T)()
{
enum ret = calcSizeInner!(T);
}
size_t calcSizeInner(T)()
{
foreach (fieldType; typeof(T.tupleof))
staticCalcSizeSL!fieldType;
return 1;
}
void noCallers() // somehow this is needed to reproduce the bug
{
}
```
Comment #1 by razvan.nitu1305 — 2023-05-18T10:03:30Z
I cannot reproduce this. This seems to have been fixed.
I'm gonna close this as WORKSFORME.
@Johan, could you please check if this still a problem and reopen if that is the case?
Comment #2 by johanengelen — 2023-05-18T12:14:33Z
This is a long time ago, so a workaround was put in the actual code back then. If the minimized test case no longer reproduces the issue, then that's it. Closing the bug report is fine.