Skip to content

Translate char to number in genType - #8988

Merged
cknitt merged 1 commit into
masterfrom
drift-8975-gentype-char
Oct 23, 2026
Merged

cknitt merged 1 commit into
masterfrom
drift-8975-gentype-char

Conversation

@cknitt

@cknitt cknitt commented Oct 23, 2026

Copy link
Copy Markdown
Member

Fixes #8975.

@genType let f = (c: char) => c generated export const f: (c:char) => char, and char is not a TypeScript type. Since #8892, char is an alias of int, but genType's builtin table in translate_type_expr_from_types.ml mapped only bool, int, float and string. Its Tconstr case doesn't expand abbreviations, so char fell through to a type reference named char. char now maps to number, like int.

Tests

typescript-react-example/src/Core.res gains char0 = (x: char) => x. The generated Core.gen.tsx has (x:number) => number, and yarn typecheck checks it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xk6AeCYpCK4SZRtHYKHGoe

Why:
    `char` is an alias of `int` since #8892, but genType's table of builtin
    types had no row for it and does not expand the abbreviation, so a
    `char` in a genType signature was emitted as the TypeScript type `char`,
    which does not exist.

Representation modified (genType's TypeScript type of char):
Example:
    @Gentype
    let char0 = (x: char) => x
Before (text): export const char0: (x:char) => char = CoreJS.char0 as any;
After (text): export const char0: (x:number) => number = CoreJS.char0 as any;

Signed-off-by: Christoph Knittel <ck@cca.io>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xk6AeCYpCK4SZRtHYKHGoe
@github-actions

Copy link
Copy Markdown

Semantic Diff

1 commit · Full page

Translate char to number in genType

7427a92 · Christoph Knittel with Claude Opus 5.5 · Oct 23, 2026

Why

char is an alias of int since #8892, but genType's table of builtin types had no row for it and does not expand the abbreviation, so a char in a genType signature was emitted as the TypeScript type char, which does not exist.

Representation modified (genType's TypeScript type of char)

@genType
let char0 = (x: char) => x

text

-export const char0: (x:char) => char = CoreJS.char0 as any;
+export const char0: (x:number) => number = CoreJS.char0 as any;

@codecov

codecov Bot commented Oct 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.22%. Comparing base (9e2f371) to head (7427a92).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #8988   +/-   ##
=======================================
  Coverage   81.22%   81.22%           
=======================================
  Files         457      457           
  Lines       63862    63862           
=======================================
  Hits        51875    51875           
  Misses      11987    11987           
Files with missing lines Coverage Δ
compiler/gentype/translate_type_expr_from_types.ml 88.46% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pkg-pr-new

pkg-pr-new Bot commented Oct 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript@8988

@rescript/belt

npm i https://pkg.pr.new/@rescript/belt@8988

@rescript/darwin-arm64

npm i https://pkg.pr.new/@rescript/darwin-arm64@8988

@rescript/linux-arm64

npm i https://pkg.pr.new/@rescript/linux-arm64@8988

@rescript/linux-x64

npm i https://pkg.pr.new/@rescript/linux-x64@8988

@rescript/runtime

npm i https://pkg.pr.new/@rescript/runtime@8988

@rescript/win32-x64

npm i https://pkg.pr.new/@rescript/win32-x64@8988

commit: 7427a92

@github-actions

Copy link
Copy Markdown

@cknitt
cknitt marked this pull request as ready for review October 23, 2026 09:25
@cknitt

cknitt commented Oct 23, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T09:27:35.955320Z 7427a92 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7427a92004

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread compiler/gentype/translate_type_expr_from_types.ml
@cknitt
cknitt requested a review from cristianoc October 23, 2026 09:50
@cknitt
cknitt merged commit f62f83c into master Oct 23, 2026
26 checks passed
@cknitt
cknitt deleted the drift-8975-gentype-char branch October 23, 2026 11:02
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.

genType emits char as a TypeScript type

2 participants