software-mansion / software-mansion/TypeGPU

[RFC] nameRegistry bug?

Open
#2,071 4 comments 0 reactions 1 assignee View on GitHub

@cieplypolar is already working on this.

Since Jan 22, 2026.

Dominant language
TypeScript
Stars
3.2k
Forks
122
Avg merge
3d 5h
Merged PRs (30d)
34

Description

I am not sure if the condition in makeValid method is sufficient.

makeValid(primer: string): string {
  if (isValidIdentifier(primer) && !this.#usedNames.has(primer)) {
    this.usedFunctionScopeNames?.add(primer);
    return primer;
  }
  return this.makeUnique(primer, false);
}

In the resolution of a forOf loop, I need to check if an identifier is free by calling ctx.getById method

let index = 'i'; // it will be valid name, no need to call this.ctx.makeNameValid
  while (ctx.getById(index) !== null) {
    index += 'i';
  }

If we were checking the function scope in the makeValid method, the while loop could be replaced with a single call to makeNameValid

Please tell me if I am correct.

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.