Skip to content

Fill generated switch cases with %todo instead of the removed failwith - #9110

Draft
cknitt wants to merge 1 commit into
masterfrom
fix-9102-todo-placeholder
Draft

cknitt wants to merge 1 commit into
masterfrom
fix-9102-todo-placeholder

Conversation

@cknitt

@cknitt cknitt commented Oct 28, 2026

Copy link
Copy Markdown
Member

The exhaustive-switch and add-missing-cases code actions fill the cases they add with a placeholder. Since #9052 removed failwith from Pervasives, that placeholder, failwith("TODO"), no longer compiles ("The value failwith can't be found").

Type_utils.Codegen.mk_fail_with_exp is replaced by mk_todo_exp, which builds %todo instead. This is what the exhaustive-switch completion already inserts; it compiles with the "Todo found" warning and throws at runtime, so the generated code keeps its meaning. Both code actions go through this one function.

The ExhaustiveSwitch and Codemod analysis snapshots now expect %todo in the generated cases.

The issue also points out that changes/deprecated-let-without-interface.fix.md says failwith and invalid_arg now warn, contradicting their removal; that sentence is dropped.

Fixes #9102

🤖 Generated with Claude Code

https://claude.ai/code/session_01Kbf3gGkPma9LAZimuQjnrP

Why:
    The exhaustive-switch and add-missing-cases code actions filled new
    cases with `failwith("TODO")`, but #9052 removed `failwith`, so the
    generated code no longer compiled. They now use `%todo`, as the
    exhaustive-switch completion already does.

Format modified (code action output):
Example:
    let f = (x: option<int>) => switch x { | Some(_) => 1 }
Before (rescript):
    switch x {
    | None => failwith("TODO")
    | Some(_) => 1
    }
After (rescript):
    switch x {
    | None => %todo
    | Some(_) => 1
    }

The deprecated-let changelog fragment no longer says that `failwith` and
`invalid_arg` warn, since they are removed.

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

Copy link
Copy Markdown

Changelog

🐛 Bug fix

  • Fill cases added by the exhaustive-switch and add-missing-cases code actions with %todo instead of the removed failwith("TODO").
  • Warn when another module uses a @deprecated let binding from a module without an interface file.

Semantic Diff

1 commit · Full page

Fill generated switch cases with %todo

f6de2bb · cknitt + Claude · Oct 28, 2026, 15:22 UTC

Why

The exhaustive-switch and add-missing-cases code actions filled new cases with failwith("TODO"), but #9052 removed failwith, so the generated code no longer compiled. They now use %todo, as the exhaustive-switch completion already does.

Format modified (code action output)

let f = (x: option<int>) => switch x { | Some(_) => 1 }

rescript

 switch x {
-| None => failwith("TODO")
+| None => %todo
 | Some(_) => 1
 }

The deprecated-let changelog fragment no longer says that failwith and invalid_arg warn, since they are removed.

@codecov

codecov Bot commented Oct 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.46%. Comparing base (85f31fb) to head (f6de2bb).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9110      +/-   ##
==========================================
- Coverage   81.46%   81.46%   -0.01%     
==========================================
  Files         460      460              
  Lines       64675    64673       -2     
==========================================
- Hits        52689    52687       -2     
  Misses      11986    11986              
Files with missing lines Coverage Δ
analysis/src/codemod.ml 68.96% <100.00%> (ø)
analysis/src/type_utils.ml 66.17% <100.00%> (-0.09%) ⬇️
🚀 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 28, 2026

Copy link
Copy Markdown

Open in StackBlitz

rescript

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

@rescript/belt

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

@rescript/darwin-arm64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/runtime

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

@rescript/win32-x64

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

commit: f6de2bb

@github-actions

Copy link
Copy Markdown

@cknitt

cknitt commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 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-28T16:42:09.028940Z f6de2bb 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

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: f6de2bb5b8

ℹ️ 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".

This branch has not been deployed

No deployments
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.

Editor code actions generate failwith("TODO"), which no longer exists

1 participant