winglang / winglang/wing

Return statement: check that all control paths return a value

Open
#457 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

📜 lang-spec-impl 🛠️ compiler roadmap
Dominant language
TypeScript
Stars
5.4k
Forks
215
Avg merge
2h 9m
Merged PRs (30d)
27

Description

https://github.com/winglang/wing/blob/main/docs/04-reference/winglang-spec.md#24-return

Compiler should add a check that all control paths return a value

Example:

bring cloud;

resource WebHook {
  api: cloud.Api;

  init() {
    this.api = new cloud.Api();
    this.api.post("/", inflight (req: cloud.ApiRequest): cloud.ApiResponse => {
      log(Json.stringify(req));
    });
  }
}

The above code should error since the inflight does not return an api response.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the return-statement section of docs/04-reference/winglang-spec.md linked in the issue and compare its requirements with the example. The work is done when the shown inflight function is rejected for lacking a return value while valid control paths that return an API response are accepted.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.