You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fail_compilation/scope_infer_diagnostic.d(34): Error: `@safe` function `scope_infer_diagnostic.outer` cannot call `@system` function `scope_infer_diagnostic.inner!(void delegate(const(char)[]) pure nothrow @nogc @safe).inner`
6
+
fail_compilation/scope_infer_diagnostic.d(28): and assigning scope variable `w` to non-scope parameter `w` calling `callee` makes it fail to infer `@safe`
7
+
fail_compilation/scope_infer_diagnostic.d(21): `w` is not `scope` because of `globalPtr = & w`
8
+
fail_compilation/scope_infer_diagnostic.d(25): `scope_infer_diagnostic.inner!(void delegate(const(char)[]) pure nothrow @nogc @safe).inner` is declared here
9
+
---
10
+
*/
11
+
12
+
// Test that scope violation error messages show WHY the callee's parameter
13
+
// is not scope when going through the @safe inference chain.
14
+
// This is similar to how @nogc violations show the full inference chain.
15
+
16
+
void* globalPtr;
17
+
18
+
voidcallee(Writer)(Writer w) @trusted
19
+
{
20
+
// This escapes w, preventing it from being inferred as scope
21
+
globalPtr = cast(void*)&w;
22
+
w("x");
23
+
}
24
+
25
+
voidinner(Writer)(scopeWriter w)
26
+
{
27
+
// Scope violation: passing scope w to non-scope parameter
0 commit comments