Skip to content

Sema: a demand on a ?? reaches its carrier, and a ?? arithmetic operand takes its peer's type, as hints (#2724) - #2742

Merged
ehartford merged 1 commit into
fix-2703from
fix-2724
Oct 26, 2026
Merged

ehartford merged 1 commit into
fix-2703from
fix-2724

Conversation

@ehartford

@ehartford ehartford commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

check_binary_operator checked a ??'s carrier with no expectation, and an
arithmetic operand that was a ?? in value context, so a generic call
whose type parameter only its result names could not infer there:
let n: i64 = parse_as("12") ?? 0 and total + (parse_as("12") ?? 0)
were "cannot infer type parameter 'T'", while a typed binding of the call
inferred. The demand on a ?? now reaches a call on its left as an
Option[E] hint, and a ?? beside a numeric operand takes that operand's
type as a hint (D103: hints, never Option demands; the operand is not
wrapped), as an untyped literal operand already did (§4.2.1). A ?? over
a narrower payload widens as before.

Test: test/behavior/behav_2724_coalesce_demand_reaches_carrier.w.

Closes #2724

@ehartford
ehartford added this pull request to stack #2743 October 26, 2026 04:07
@ehartford ehartford changed the title fix 2724 Sema: a demand on a ?? reaches its carrier, and a ?? arithmetic operand takes its peer's type, as hints (#2724) Oct 26, 2026
…nd takes its peer's type, as hints (#2724)

check_binary_operator checked a `??`'s carrier with no expectation, and an
arithmetic operand that was a `??` in value context, so a generic call
whose type parameter only its result names could not infer there:
`let n: i64 = parse_as("12") ?? 0` and `total + (parse_as("12") ?? 0)`
were "cannot infer type parameter 'T'", while a typed binding of the call
inferred. The demand on a `??` now reaches a call on its left as an
`Option[E]` hint, and a `??` beside a numeric operand takes that operand's
type as a hint (D103: hints, never Option demands; the operand is not
wrapped), as an untyped literal operand already did (§4.2.1). A `??` over
a narrower payload widens as before.

Test: test/behavior/behav_2724_coalesce_demand_reaches_carrier.w.
@ehartford

Copy link
Copy Markdown
Contributor Author

Battery GREEN on the stack top ddb68e8 (with run tools/battery.w, pinned seed nightly-20261025-local-1-c88f3eeff0bc): gate, uat and battery-checks all green; behavior-tests 1949/1949 ran, benchmarks-check 8 programs, pub-lint-check clean. The previous run's three reds (behav_str_to_cstr_interior_nul_panics now expects 134 under #2669, benchmarks/run.w binds its texts under #2659, with_self_exe is no longer pub under #2647) are fixed in their layers.

@ehartford
ehartford marked this pull request as ready for review October 26, 2026 04:31
@ehartford
ehartford merged commit 2360317 into main Oct 26, 2026
@ehartford
ehartford deleted the fix-2724 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 ?? in arithmetic operand position gives its carrier no demand: total += s.parse() ?? 0 cannot infer

1 participant