rescript-lang / rescript-lang/rescript-lang.org

Possible addition to discussion of loops

Open
#460 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
MDX
Stars
1.9k
Forks
260
Avg merge
3d 9h
Merged PRs (30d)
17

Description

Regarding https://rescript-lang.org/docs/manual/latest/control-flow#for-loops
It appears that the body of a for loop must evaluate to unit. This code:

let n: array<int> = []
for i in 1 to 3 {
  Js.Array2.push(n, i)
}

produces this error (the fix is to pipe to ignore):

[E] Line 3, column 2:

This has type: int
  Somewhere wanted: unit

Is this worth documenting?

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 control-flow documentation at the linked for-loops section and review how loop-body expressions are currently described. Confirm the shown example and error behavior, then document that the body must evaluate to unit, including the ignore workaround; the section should explain the requirement clearly to readers.

Written by the indexing model from the issue text.

Assessment

Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.