Skip to content

fix: add missing [Env] parameter to array map signature - #13500

Open
0x11semprez wants to merge 11 commits into
noir-lang:masterfrom
0x11semprez:docs/map-env-param
Open

fix: add missing [Env] parameter to array map signature#13500
0x11semprez wants to merge 11 commits into
noir-lang:masterfrom
0x11semprez:docs/map-env-param

Conversation

@0x11semprez

@0x11semprez 0x11semprez commented Aug 10, 2026

Copy link
Copy Markdown

Fix: add missing [Env] parameter to array map signature

Summary

The documentation for the array map function does not show the [Env] parameter,
while other functions of the same module (for_each, for_eachi, ...) document it.
The stdlib source does declare [Env], and code relying on it compiles without any
error, so this appears to be a documentation inconsistency rather than a library bug.

Location

Signature shown in the docs (incorrect)

fn map<U>(self, f: fn(T) -> U) -> [U; N]

Signature declared in the stdlib (correct)

pub fn map<U, Env>(&self, f: fn[Env](T) -> U) -> [U; N]

Note that there are two discrepancies: the missing Env generic / fn[Env] closure
type, and self vs &self.

For comparison — for_each, documented correctly

fn for_each<Env>(self, f: fn[Env](T) -> ())

Reproduction

The following snippet compiles and passes:

fn main() {
    let test = 5;
    let a = [1, 2, 3];
    let b = a.map(|x| x * test);
    assert(b == [5, 10, 15]);
}

The closure captures test from its environment, so it cannot have type
fn(T) -> U as documented — a non-capturing function type. It is accepted,
which confirms the real signature takes fn[Env](T) -> U.

Expected

The docs entry for map should show the same [Env] parameter as the rest of the
module, and match the receiver used in the stdlib.

Environment

  • Nargo version: <sortie de nargo --version>
  • Docs version: <stable / dev>

Additional notes

Happy to open a PR fixing the docs page if you point me to the source file.

semprez is happy

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution to the Noir language.

Please do not force push to this branch after the Noir team have started review of this PR. Doing so will only delay us merging your PR as we will need to start the review process from scratch.

Thanks for your understanding.

@0x11semprez 0x11semprez changed the title docs: add missing [Env] parameter to array map signature fix: add missing [Env] parameter to array map signature Aug 10, 2026
@0x11semprez

Copy link
Copy Markdown
Author

@TomAFrench please could you review my pr, if you have the time sir

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant