Skip to content

Sema: a view into a parenthesized temporary is refused like any other (#2659) - #2735

Merged
ehartford merged 1 commit into
fix-2669from
fix-2659
Oct 26, 2026
Merged

ehartford merged 1 commit into
fix-2669from
fix-2659

Conversation

@ehartford

@ehartford ehartford commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

record_view_producer_origins marks a view whose receiver is a statement
temporary (#962), so a binding or return of it is refused (§21.1). It read
the receiver node's recorded type and place kind; a parenthesized receiver
is an NK_GROUPED with no type of its own, so (read_file(p) ?? "").trim()
and (f().unwrap()).trim() were accepted, and the binding read the freed
temporary (a 141-byte title reached a child process as 142 empty
arguments). The receiver's grouping is peeled before the check, as
view_into_temporary_type already peels it. tools/corpus_bench.w had the
shape twice and now binds the text first.

Test: test/compile_errors/err_2659_view_through_coalesce_temporary.w.

Closes #2659

@ehartford
ehartford added this pull request to stack #2743 October 26, 2026 04:07
@ehartford ehartford changed the title fix 2659 Sema: a view into a parenthesized temporary is refused like any other (#2659) Oct 26, 2026
…#2659)

record_view_producer_origins marks a view whose receiver is a statement
temporary (#962), so a binding or return of it is refused (§21.1). It read
the receiver node's recorded type and place kind; a parenthesized receiver
is an NK_GROUPED with no type of its own, so `(read_file(p) ?? "").trim()`
and `(f().unwrap()).trim()` were accepted, and the binding read the freed
temporary (a 141-byte title reached a child process as 142 empty
arguments). The receiver's grouping is peeled before the check, as
view_into_temporary_type already peels it. tools/corpus_bench.w had the
shape twice and now binds the text first, as benchmarks/run.w does at
four sites (the battery's benchmarks-check refused it once the fix landed).

Test: test/compile_errors/err_2659_view_through_coalesce_temporary.w.
@ehartford
ehartford marked this pull request as ready for review October 26, 2026 04:31
@ehartford
ehartford merged commit 9fcb78a into main Oct 26, 2026
@ehartford
ehartford deleted the fix-2659 branch October 26, 2026 04:32
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 view through ?? loses its temporary's origin: (read_file(p) ?? "").trim() is accepted and reads freed memory (§21.1, D22)

1 participant