Skip to content

explore: ReScript (.res/.resi) language support (#532)#533

Merged
justrach merged 2 commits into
release/0.2.5824from
feat/rescript-532
Jun 4, 2026
Merged

explore: ReScript (.res/.resi) language support (#532)#533
justrach merged 2 commits into
release/0.2.5824from
feat/rescript-532

Conversation

@justrach

@justrach justrach commented Jun 4, 2026

Copy link
Copy Markdown
Owner

Closes #532.

Adds ReScript as a first-class indexed language, following the existing per-language line-parser pattern (mirrors how .r #215 and .tf #108 were added).

What

  • Detection: .res and .resi → new rescript language.
  • parseRescriptLine extracts:
    ReScript Symbol kind
    let f = (…) => … / let rec / and f = … => function
    let x = value (no arrow) constant
    type t = … type_alias
    module M = { … } struct_def
    module type S = { … } interface_def
    external name: T = "…" function
    open M / include M import
  • Leading @decorator / @decorator(args) are stripped first, so a decorated @val external … or @react.component\nlet make still resolves.
  • // and /* */ comments are skipped (ReScript joins the C-style block-comment group + isCommentOrBlank). langHasCallSites/isCheckableCode fall through their else arms correctly (call-sites: yes, delimiter-balance check: no).

Tests (failing-first, per CLAUDE.md)

Commit 1 adds issue-532 tests that fail on the base branch (.res.unknown, empty outline); commit 2 implements support and turns them green:

  • test_parser.zig — full outline of a .res file (module/type/let/external/open).
  • test_explore.zigdetectLanguage for .res/.resi.

zig build test passes clean (0 failures).

End-to-end (codedb outline on a real .res)

✓ src/User.res  rescript  25 lines  ⚡ 4.0µs
  L1   import      Belt
  L3   struct_def  User
  L4   type_alias  t
  L9   function    make
  L11  function    greet
  L14  type_alias  status
  L18  constant    defaultName
  L20  function    fib
  L22  function    setTimeout   (decorated @val external)
  L24  function    helper       (and-binding)

Known limitations (v1, additive)

Line-based like the sibling parsers: nested module members are flattened into the top-level outline, and exception/variant constructors are not yet emitted as symbols. These can be follow-ups; nothing here is a filter, so recall is never reduced.

🤖 Generated with Claude Code

justrach and others added 2 commits June 4, 2026 23:34
Adds issue-532 tests asserting .res/.resi detect as `rescript` and that a
.res file's module/type/let/external symbols and `open` import are parsed.
Both fail on the current branch: .res falls through detectLanguage to
.unknown, so no parser runs and the outline is empty.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds a `rescript` language with .res/.resi detection and a line-based
parseRescriptLine that extracts: let/and bindings (function when the RHS
has a `=>` arrow, constant otherwise), type → type_alias, module →
struct_def (module type → interface_def), external → function, and
open/include → import. Leading @decorators are stripped so a decorated
`@val external` / `@react.component let` still resolves; // and /* */
comments are skipped. ReScript joins the C-style block-comment group and
isCommentOrBlank; langHasCallSites/isCheckableCode fall through correctly.

Closes #532.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown

Benchmark Regression Report

Thresholds: 10.00% and 50,000 ns absolute delta

NOISE means the percentage threshold was exceeded, but the absolute delta was too small to fail CI.

Tool Base (ns) Head (ns) Delta Abs Delta (ns) Status
codedb_bundle 107582 115517 +7.38% +7935 OK
codedb_changes 11544 11068 -4.12% -476 OK
codedb_context 1119983 1187920 +6.07% +67937 OK
codedb_deps 243 240 -1.23% -3 OK
codedb_edit 54339 47408 -12.76% -6931 OK
codedb_find 10203 10580 +3.69% +377 OK
codedb_hot 27801 25867 -6.96% -1934 OK
codedb_outline 35236 38295 +8.68% +3059 OK
codedb_read 17274 17186 -0.51% -88 OK
codedb_search 25998 28066 +7.95% +2068 OK
codedb_snapshot 69866 71034 +1.67% +1168 OK
codedb_status 9996 9659 -3.37% -337 OK
codedb_symbol 19820 19134 -3.46% -686 OK
codedb_tree 46469 50529 +8.74% +4060 OK
codedb_word 12513 12450 -0.50% -63 OK

@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: 96e941d0b1

ℹ️ 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 src/explore.zig
llvm_ir,
mlir,
tablegen,
rescript,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Avoid overflowing telemetry's language mask

When a project contains a .res/.resi file and telemetry is enabled (the default), recordCodebaseStats casts @intFromEnum(entry.value_ptr.language) to u5 before shifting a u32 mask. Adding rescript after tablegen gives it enum value 32, which cannot fit in u5, so startup/status telemetry collection traps instead of completing the scan; the telemetry mask/list needs to be widened or otherwise updated for the new language.

Useful? React with 👍 / 👎.

@justrach justrach merged commit 24a74ee into release/0.2.5824 Jun 4, 2026
1 check passed
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