https://issues.dlang.org/show_bug.cgi?id=17763
Walter Bright <bugzi...@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |INVALID --- Comment #3 from Walter Bright <bugzi...@digitalmars.com> --- (In reply to ZombineDev from comment #0) > The problem is that the compiler disallows explicitly slicing a static array > and passing the slice to a scope parameter, while if you rely on the > implicit slicing it works without a problem. Let's examine: > use(c); // OK - this compiles. The address of c is implicitly taken by its coercion to the parameter type of Context[]. But this is allowed because the parameter is 'scope', and it cannot escape. > use(c[]); // NG - doesn't compile, though should be > // equivalent to the statement above. What's happening here is the semantic analysis is bottom up, meaning `c[]` is evaluated without regard to what context it appears in. The compiler doesn't see that the result is being passed as `scope`, and so assumes the worst, and issues an error. It is not a bug in the compiler. Trying to add some form of top down in addition to bottom up is a huge increase in complexity, and will produce all kinds of weird corner cases. You can reopen it as an enhancement request if you prefer, but I don't think it is practical to implement at least in the near future. --