Bug 23760 – Error: unknown

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-03-06T19:45:54Z
Last change time
2023-03-16T01:20:56Z
Keywords
pull
Assigned to
No Owner
Creator
John Colvin

Comments

Comment #0 by john.loughran.colvin — 2023-03-06T19:45:54Z
The code below produces the following error when compiled, so I am obeying its command: Error: unknown, please file report on issues.dlang.org app.d(19): Error: `(A).state` cannot be resolved app.d(7): Error: template instance `arsd.jni.JavaBridge!(A)` error instantiating app.d(29): instantiated from here: `JavaClass!("fin", A)` app.d(26): Error: mixin `arsd.jni.JavaClass!("fin", A).JavaClass.ImportExportImpl!(A)` error instantiating module arsd.jni; static T (){ } template ImportExportImpl(Class) { arsd.jni.JavaBridge!(Class) _javaDBridge; } template ImportExportImpl() { } class JavaBridge(Class) { static foreach(memberName; __traits(derivedMembers, Class)) { // validations static if(is(typeof(__traits(getMember, Class, memberName)))) static assert(1); // FIXME // implementations static foreach(oi; __traits(getOverloads, Class, memberName)) mixin JavaImportImpl; } } class JavaClass(string javaPackage, CRTP) { mixin ImportExportImpl!CRTP; } class A : JavaClass!("fin", A) { State* state; }
Comment #1 by razvan.nitu1305 — 2023-03-07T11:06:42Z
A reduced version: class JavaBridge(Class) { static if(is(typeof(__traits(getMember, Class, "state")))) {} alias T = __traits(getOverloads, Class, "state"); } class JavaClass(CRTP) { JavaBridge!(CRTP) _javaDBridge; } class A : JavaClass!A { State* state; }
Comment #2 by razvan.nitu1305 — 2023-03-07T11:48:15Z
The problem seems to stem from the fact that the first time `State` is analyzed as a type is when the type is requested via `typeof`. In that context, semantic analysis is done with gagged errors, therefore you don't get the user friendly error message. Next time it is analyzed is when traits(overloads) is requested on `state`. By that time the compiler just sees that `state` has an erroneous type but doesn't know the reason.
Comment #3 by dlang-bot — 2023-03-07T13:29:00Z
@RazvanN7 created dlang/dmd pull request #14963 "Fix Issue 23760 - Unknown error for type used with traits(getOverloads)" fixing this issue: - Fix Issue 23760 - Unknown error for type used with traits(getOverloads) https://github.com/dlang/dmd/pull/14963
Comment #4 by dlang-bot — 2023-03-08T14:03:19Z
dlang/dmd pull request #14963 "Fix Issue 23760 - Unknown error for type used with traits(getOverloads)" was merged into stable: - d99e6d2cd1aef06a00b595152f0b04e7fb736d1f by RazvanN7: Fix Issue 23760 - Unknown error for type used with traits(getOverloads) https://github.com/dlang/dmd/pull/14963
Comment #5 by dlang-bot — 2023-03-16T01:20:56Z
dlang/dmd pull request #14992 "merge stable" was merged into master: - 2a4d6d286fa27f8bafa0d4d628411435da16677f by Razvan Nitu: Fix Issue 23760 - Unknown error for type used with traits(getOverloads) (#14963) https://github.com/dlang/dmd/pull/14992