https://issues.dlang.org/show_bug.cgi?id=17934
Mike Franklin <slavo5...@yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |slavo5...@yahoo.com --- Comment #7 from Mike Franklin <slavo5...@yahoo.com> --- (In reply to Martin Nowak from comment #0) > /** > There seems to be now way to write this functions so > that the compiler infers the return value as scope. > */ > List list() @trusted > { > return List(malloc(1)); > } > > void test() @safe > { > Elem elem; > { > //scope l = list(); // works with explicit scope > auto l = list(); // not inferred as scope > elem = l.front; // escapes, b/c l isn't scoped > } > } Why does `scope` need to be inferred? What's wrong with the user being required to attribute `scope` to the declaration. What about having `scope` apply to return values of functions, so `list()` could be written as `scope List list() @trusted`? --