Repository navigation
fix(ts): return std's next from a function other than next as an Option - #258
Conversation
Quest-Claim: cabcf1da3bd9ef9d
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # ts/fixtures/lang/expected/harness.ts # ts/fixtures/lang/src/harness.rs
…ts call Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # ts/fixtures/lang/expected/harness.ts # ts/fixtures/lang/src/harness.rs # ts/fixtures/reject/census.md
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 53 minutes. View limit details
No actionable comments were generated in the recent review.
|
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: b524ab60a739af404c530d5f1bcb237923b4b939.
No actionable bugs found in the inspected changes. Excluding the return place from protocol-local inference sends ordinary returned next() calls through the existing Option conversion, including the distinct nested-Option sentinel. An actual Iterator::next still explicitly marks its return place for the protocol representation.
Direction is sound: this narrow exclusion fixes the boundary without adding another conversion path at return. The differential fixture and snapshots cover generic, borrowed, local and crate-defined iterators; the unsupported nested-item consumers are tracked separately rather than silently treated as supported.
Verification limits: GitHub-only static review of inference, call lowering, iterator conversion and regression fixtures, with an independent pass. No compiler builds, differential tests or census runs were executed; reported checks were not independently verified.
Problem
A function other than an
Iterator::nextimpl that returnsit.next()directly emitted the protocol's raw item orrt.DONEinstead of theOptionits signature declares, sotscrejected it. Generic or not:first<I: Iterator>(mut it: I),&mut I,&mut slice::Iter,Chars, the crate's own iterators, and a slice iterator made in the function (stepped in place toreturn i < s.length ? s[i++] : rt.DONE) all hit it. Found by #241, on main.Approach
find_next_resultsmarks the locals anextassigns that hold the protocol's value unconverted. Its use check walks places, and MIR'sreturnreads_0as a local, not a place, so anextinto the return place always passed. The return place is now never a protocol local, except in anextitself, which already marks it. One condition ints/src/lower/mir/mod.rs; the range-specificRETURN_PLACEexclusion beside it is now redundant and dropped.The other
Option-returning calls the quest named (next_back,nth,last,Peekable::peek, sliceget) already converted when returned directly; the new case proves each against native wasm32.Differential case
iters::returnedin the lang fixture: each of those returned from generic and non-generic functions, overu8items andOption<u8>items (Option<Option<u8>>returns, soNoneandSome(None)stay apart), through&mut, the crate's own iterators, and iterators made in the function.Impact
nextis nowrt.iterToOption(it.next()), typed as declared.nextis returned is no longer stepped in place (it was wrong there). Dropped: that stepping, for this shape only.&mut dyn Iterator's returnednextnow also refuses at its call (rejectfixture, 12:4), as a non-returned call already did; before, the protocol path skipped that refusal. The parameter's refusal was already there.Alternatives
visit_localsoreturncounts as a whole-value move. Same result for this case, more surface; the return place is the only localreturnreads.returnwithrt.iterToOptionwhile keeping the stepped form. Saves anrt.Iterfor a rare shape; not worth the extra path.Follow-ups
nthandlast(andfind, already inreject) of an iterator ofOptionare refused at their span; found while writing the nested cases.Review
quest review, round 3)just cipassed locally on 52bbb5b.🤖 Generated with Claude Code
(written by Claude Opus 5.5)