Skip to content

Tests: generator restrictions coverage (§13) #504

Closed

Description

@ehartford

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

  1. Add a compile-error test under test/compile_errors/ for a gen fn that attempts to await an async value.
  2. Lock the diagnostic with //! expect-check-fail: await is not allowed in generator function.
  3. Keep any async helper local to the fixture and minimal.
  4. 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

  • .await inside 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

  1. ehartford commented on Jul 3, 2026

    @ehartford
    ContributorAuthor

    Closing — await inside a generator (gen fn) rejected, pinned by err_generator_await (13f4f88). §13. (Also satisfies #482's negative.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions