digitalmars.D.learn - error forward references if scope
- vit (36/36) Mar 12 2022 Hello,
- Salih Dincer (18/21) Mar 12 2022 I think you meant build instead of touch?
Hello, why this code compile without problems: ```d struct Query{ public const SharedPtr!Builder builder; } interface Builder{ void build(ref Query query); } struct SharedPtr(T){ enum touch_T = __traits(hasMember, T, "touch"); //... } void main(){ } ``` but if `ref Query query` is scope then there is error? ```d struct Query{ public const SharedPtr!Builder builder; } interface Builder{ void build(scope ref Query query); //SCOPE } struct SharedPtr(T){ enum touch_T = __traits(hasMember, T, "touch"); //... } void main(){ } ``` ``` src/app.d(3,1): Error: no size because of forward references src/app.d(4,18): Error: template instance `app.SharedPtr!(Builder)` error instantiating ```
Mar 12 2022
On Saturday, 12 March 2022 at 13:12:25 UTC, vit wrote:```d enum touch_T = __traits(hasMember, T, "touch"); ```I think you meant build instead of touch? ```d struct Query { public const SharedPtr!Builder builder; } interface Builder { void build(ref Query query); } struct SharedPtr(T) { enum touch_T = __traits(hasMember, T, "build"); } import std.traits, std.stdio; void main() { Query q; q.builder.touch_T.writeln(" #build"); } // true #build ```
Mar 12 2022