Bug 21501 – [REG 2.089.1] undefined identifier in package when using mixin and cyclic imports
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-12-23T12:42:10Z
Last change time
2021-04-03T01:03:44Z
Keywords
pull
Assigned to
No Owner
Creator
Tim
Comments
Comment #0 by tim.dlang — 2020-12-23T12:42:10Z
//////////////// test/a.d ////////////////
module test.a;
import test.b;
import test.c;
alias Identity(T) = T;
struct A
{
Identity!(mixin(q{test.c.C})) data;
}
//////////////// test/b.d ////////////////
module test.b;
import test.a;
struct B
{
A data;
}
//////////////// test/c.d ////////////////
module test.c;
alias C = int;
//////////////////////////////////////////
Running dmd -c test/a.d results in the following error:
test/a.d-mixin-10(10): Error: undefined identifier c in package test, perhaps add static import test.c;
Running dmd -c test/b.d test/a.d test/c.d instead does not result in an error. The order of the files is important, because dmd -c test/a.d test/b.d test/c.d does result in the error.
The error happens with dmd v2.089.1, while it works normally with dmd v2.089.0.
It looks like https://github.com/dlang/dmd/pull/10584 introduced it.
Comment #1 by boris2.9 — 2020-12-23T13:52:58Z
I remember this issue, the problem is that the compiler has a different logic to resolve a qualified type vs a dot expression, mixin is not required to reproduce it:
struct A
{
alias a = test.c.C; // works
auto b = test.c.C; // fails even if C is a variable
}
Currently this kind of mixin can parse both types and expressions but it will prefer expressions, so it's hitting the wall.
I'll try to see what can I do.
Comment #2 by dlang-bot — 2020-12-30T02:45:06Z
@BorisCarvajal created dlang/dmd pull request #12074 "Fix Issue 21501 - undefined identifier in package when using mixin an…" fixing this issue:
- Fix Issue 21501 - undefined identifier in package when using mixin and cyclic imports
https://github.com/dlang/dmd/pull/12074
Comment #3 by dlang-bot — 2020-12-30T04:42:23Z
dlang/dmd pull request #12074 "Fix Issue 21501 - undefined identifier in package when using mixin an…" was merged into master:
- bb05f01b4de05b6a64d6ba96db16b22d9ca772e8 by Boris Carvajal:
Fix Issue 21501 - undefined identifier in package when using mixin and cyclic imports
https://github.com/dlang/dmd/pull/12074
Comment #4 by dlang-bot — 2021-04-03T01:03:44Z
dlang/dmd pull request #12350 "[dmd-cxx] More fixes for package import visibility" was merged into dmd-cxx:
- fd4690803a2aa3b9107826a087f40f115f9d475e by Boris Carvajal:
[dmd-cxx] Fix Issue 21501 - undefined identifier in package when using mixin and cyclic imports
https://github.com/dlang/dmd/pull/12350