Repository navigation
Offer the null check alone where a 'mutating' call cannot use a '??' fallback - #321
Conversation
…fallback, fixes #156 Co-authored-by: DicyAgent <354226518+DicyAgent@users.noreply.github.com>
Co-authored-by: DicyAgent <354226518+DicyAgent@users.noreply.github.com>
AlexDicy
left a comment
There was a problem hiding this comment.
"so a '??' fallback would change only a copy"
Where is this coming from? It's written as if the user attempted it or if it was suggested somewhere else. It's a bit confusing to me.
Does this message respect all of the diagnostic rules?
Co-authored-by: DicyAgent <354226518+DicyAgent@users.noreply.github.com>
…ck would change Co-authored-by: DicyAgent <354226518+DicyAgent@users.noreply.github.com>
|
Pushed The copy clause is gone. The reason now says where the thought comes from - the fallback this refusal is declining - and states it as a property of the change, not of something the reader had written: Re-checked against the rules, as asked:
Rule 4 also turned up a defect in the write reason added by Verified on linux-x64 at |
Co-authored-by: DicyAgent <354226518+DicyAgent@users.noreply.github.com>
|
Round 2 fixes pushed at The join variant of the refusal (rules 3, 5, 21). A The write form says the same. The whole advice is one sentence per join, so three branches no longer repeat the fix three times. Where a null check of the branches is the fix, a read, the clause now names the join written plainly, The PR description no longer quotes the removed Pinned: a unit test in Verified on linux-x64 with a compiler built from this branch: the two shapes and their fixes, the same-guard join, a three-branch join, a read through the same access keeping |
AlexDicy
left a comment
There was a problem hiding this comment.
The error message is way too long and verbose
Co-authored-by: DicyAgent <354226518+DicyAgent@users.noreply.github.com>
|
Pushed 12712fa: merged origin/main (4fb2574) into this branch. Conflicts in memberaccess.ens and nullguidance.ens were resolved onto main's NullJoin/verb signature with this PR's noFallback appended; no message text changed. Full |
Co-authored-by: DicyAgent <354226518+DicyAgent@users.noreply.github.com>
Co-authored-by: DicyAgent <354226518+DicyAgent@users.noreply.github.com>
|
Pushed 19a8503 (on top of 12712fa), still a draft. Round 4 changes:
Full suite is running on this head. |
|
Full suite is green at 19a8503 (636/636, bootstrap fixpoint identical, semacheck 211/211). PR stays a draft. |
Co-authored-by: DicyAgent <354226518+DicyAgent@users.noreply.github.com>
|
Round 5 pushed: 45e0064 (on 19a8503). PR stays a draft.
Every changed shape is pinned in |
AlexDicy
left a comment
There was a problem hiding this comment.
Cannot call 'bump' on 'holder?.plain': a '?.' gives a copy, so changes to it would be lost. Check 'holder' for null first ('if (holder != null)') and write 'holder.plain'.
Co-authored-by: DicyAgent <354226518+DicyAgent@users.noreply.github.com>
|
Pushed 753a1f8: the mutating call through '?.' on a name now reads "Cannot call 'bump' on 'holder?.plain': a '?.' gives a copy, so changes to it would be lost. Check 'holder' for null first ('if (holder != null)') and write 'holder.plain'." Wording as in the review; the join and write refusals are unchanged. PR stays a draft. |
…ain-mutating-fallback
Co-authored-by: DicyAgent <354226518+DicyAgent@users.noreply.github.com>
|
Pushed de4c9e0 (on 753a1f8, merged with origin/main 44e69e1). Still a draft.
|
Closes #156
local?.plain.bump()is refused for a nulllocalwith a message that offered a??fallback, which the call then refuses because a fallback value is no place to change. The refusal now leaves the fallback out where the change cannot land in one, and says why:The member being called is looked up on the struct the optional holds, so a read, a class, and a method that changes nothing keep the fallback they had.
A write through
?.,local?.plain.value = 2, had the same wrong offer, since a write needs a place too. It drops the fallback where the change lands in a struct value, and keeps it where the value is a class or an array, which change through the reference a fallback carries just as well.A
?:is no variable, a field or an array element either, so a change on one,(flag ? first?.plain : second?.plain).bump()or the write form, stores the value in a local and checks that instead of offering a null check of the branches that the change could not land in.