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
{{ message }}
Repository navigation
Commit 0c2de35
Browse filesBrowse the repository at this point in the historyBrowse files
fix(roslyn): a callback that takes a token outside a region entry is refused
A token exists only inside a region. The lowering held that for methods (a token
parameter is refused) and for locals (a token local outside a region is
refused), and not for the one remaining callable: a lambda or a local function.
Those were read only as the in-place body of a region entry. A callback that
took a token any other way was not lowered at all:
public static class LetterProtocol
{
[ProtocolRegion] public static void WithOpen(Letter l, OpenLetterRegion body) => ...;
public static void Peek(Letter l, OpenLetterRegion body) => body(new OpenLetter(l));
}
LetterProtocol.Peek(letter, open => { open.Seal(); open.Seal(); });
`Peek` is a method of the protocol's own type that is not marked as a region
entry. The declaring type is trusted, so nothing objects to the hand-out; the
callback is consumer code, and it was absent from the facts. Exit 0, a token
spent twice, clean.
Now every lambda and local function in consumer code that takes a token must be
the body of a region entry that was lowered; any other one is a refusal. The
protocol's own types are exempt (they hand tokens out), and a method already
refused does not get a second message for its callbacks.
refused/R16 (a lambda) and refused/R17 (a local function passed as a method
group) pin it; both exit 0 on main's extractor. No committed fact moves: every
lambda in the existing cases is a lowered region body.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
continue;// no token; or the protocol's own types, which hand tokens out
231
+
refusals.Add(At(file,callable,
232
+
$"a callback that takes protocol token '{taken.Type.Name}' is not the in-place body of a region entry: a token exists only inside a region, and code that receives one any other way is not analysed"));
233
+
}
234
+
205
235
// A region entry outside any method body (an accessor, a field initializer, a
0 commit comments