Repository navigation
Description
Summary
Add regression coverage for .await inside generators. The compiler already rejects it, but the requirement is currently verified manually rather than by a dedicated compile-error test.
Spec
docs/with-specification.md:7310-7338 distinguishes generators from async functions. docs/with-specification.md:7320 says generators suspend at yield while async functions suspend at scheduler points. docs/with-specification.md:7329 says a gen fn cannot use .await. docs/requirements.md:7031-7048 records the §14.20 generator/async split, including requirement 14.20.1.14.
Current state
src/SemaCheck.w:3170-3206 checks NK_AWAIT. When current_fn_is_gen is set, src/SemaCheck.w:3174-3175 emits await is not allowed in generator function. Generator yield checking is separate at src/SemaCheck.w:3240-3260.
test/spec/spec_ss13_4_generators.w covers positive generator behavior. No dedicated test/compile_errors/err_generator_await.w-style test exists, and out/req-campaign/g07.tsv records this requirement as manually verified only.
Implementation plan
- Add a minimal compile-error test with a
gen fnwhose body attempts to.awaitan async result. - Use
//! expect-check-fail: await is not allowed in generator functionso the test locks the existing diagnostic. - Keep the fixture minimal enough that the only expected failure is the generator/await rule, not missing runtime or scheduler setup.
- If the async fixture needs helper definitions, reuse the smallest existing async test pattern instead of introducing new async semantics.
Test plan
Run the new compile-error test directly, then run with build :test. Confirm the test fails if the current_fn_is_gen guard in check_await is removed.
Acceptance criteria
- A compile-error test covers
.awaitinsidegen fn. - The expected diagnostic is the existing
await is not allowed in generator functionmessage. - Positive generator tests and positive async-await tests continue to pass.
Dependencies
Overlaps #504, which tracks the same restriction from the §13.4 requirements side. One shared test can satisfy both if named and documented clearly.
Traceability
From the requirements campaign (docs/requirements.md, spec v7.1). Affected requirement IDs: 14.20.1.14.
Activity
ehartford commentedon Jul 3, 2026
Closing — await inside a generator (gen fn) rejected, pinned by err_generator_await (13f4f88, 'await is not allowed in generator function'). Duplicate of the negative added for #504. §14/§13.