Repository navigation
Description
Summary
Add test coverage for the §13.4 generator restriction that generators cannot use .await. The implementation exists; the gap is a stable compile-error fixture.
Spec
docs/with-specification.md:5422-5425 states that gen fn and async fn are distinct and a generator cannot use .await. docs/requirements.md:5015-5018 records requirement 13.4.1.22: generators cannot use .await; use async for asynchronous streams.
Current state
src/SemaCheck.w:3170-3206 checks await expressions, and src/SemaCheck.w:3174-3175 emits await is not allowed in generator function when the current function is a generator. Generator tests in test/spec/spec_ss13_4_generators.w cover normal yield behavior, and test/compile_errors/err_generator_yield_local_ref.w:1 covers yielded local-reference rejection. There is no dedicated compile-error fixture for .await inside a generator.
Implementation plan
- Add a compile-error test under
test/compile_errors/for agen fnthat attempts to await an async value. - Lock the diagnostic with
//! expect-check-fail: await is not allowed in generator function. - Keep any async helper local to the fixture and minimal.
- Reference the same fixture from the requirements campaign evidence for both §13.4 and §14.20 if campaign bookkeeping is updated later.
Test plan
Run the new compile-error test and with build :test. Verify that removing or bypassing the current_fn_is_gen branch in check_await makes the new test fail.
Acceptance criteria
.awaitinside a generator is covered by a compile-error test.- The test asserts the generator-specific diagnostic.
- The fixture does not depend on unrelated async runtime behavior.
- Existing positive generator and async tests remain green.
Dependencies
Overlaps #482. Do not add two near-identical fixtures; one well-named test can close both coverage gaps.
Traceability
From the requirements campaign (docs/requirements.md, spec v7.1). Affected requirement IDs: 13.4.1.22.
Activity
ehartford commentedon Jul 3, 2026
Closing — await inside a generator (gen fn) rejected, pinned by err_generator_await (13f4f88). §13. (Also satisfies #482's negative.)
test: coverage-sweep batch 4 (#497 #504 #506 #524 #525 #531 #534)