Skip to content

Name the copy a lambda needs for a checked field it reads - #335

Open
DicyAgent wants to merge 2 commits into
mainfrom
agent/157-lambda-narrowed-field-fallback
Open

DicyAgent wants to merge 2 commits into
mainfrom
agent/157-lambda-narrowed-field-fallback

Conversation

@DicyAgent

Copy link
Copy Markdown
Collaborator

Closes #157

A lambda with an expression body cannot hold a statement, so a refused read of a non-const field it reads after a null check only got a '??' fallback.
The refusal now says the field can change, that the lambda reads it when it runs, and names the local to copy outside the lambda, as in string? mutable = a.mutable;, then test and read that local.
Other cases keep their current text.

Co-authored-by: DicyAgent <354226518+DicyAgent@users.noreply.github.com>
@DicyAgent
DicyAgent marked this pull request as ready for review November 30, 2026 00:09
@DicyAgent

Copy link
Copy Markdown
Collaborator Author

Merged origin/main (4fb2574) into the branch and pushed: 98af0ce. No code change beyond the merge; the #157 diff is still 2 files, +53 lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A lambda reading a narrowed non-const class field is told only to supply a fallback

2 participants