Skip to content

Return the parser's warnings instead of printing them - #9363

Merged
cknitt merged 1 commit into
parser-driver-to-commonfrom
parser-warnings-as-values
Nov 21, 2026
Merged

cknitt merged 1 commit into
parser-driver-to-commonfrom
parser-warnings-as-values

Conversation

@cknitt

@cknitt cknitt commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Stacked on #9362. The parser printed its one warning, for the deprecated (. ...) syntax, through the compiler's warning reporting when it finished parsing. For a parser library, warnings should be values the caller decides about.

  • A new parser module, Res_warning, has a warning kind, Deprecated_uncurried_dot, a record of kind and location, and message, which keeps the current text.
  • The parser keeps Res_warning.t values, and Res_parser.finish no longer prints them. Res_driver's parse results have a new warnings field.
  • Syntax_driver.report_warnings turns them into Warnings.Deprecated and reports them through Location.prerr_warning, as before. It is called right after parsing, before syntax errors are printed, so text, locations and order stay the same, by: the compiler's parse_implementation/parse_interface, bsc -format, Res_multi_printer, res_parser and the playground.
  • Editor analysis, rescript-tools and the snippets the compiler parses for error hints no longer print the warning. The editor shows warnings from the build. A changelog fragment notes this.
  • A unit test checks the returned warnings: kind, position and source order.

The syntax test snapshots with the warning (for example uncurriedLegacyDot.res.txt) are unchanged.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QchYQ7itFLVLUmZ368okjH

@cknitt
cknitt added this pull request to stack #9361 November 20, 2026 22:09
@cknitt cknitt added the changelog:skip No release notes needed label Nov 20, 2026
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Changelog

💅 Polish

  • Editor analysis and rescript-tools no longer print the deprecation warning for the (. ...) syntax to stderr. The build still reports it.

Semantic Diff

1 commit · Full page

✏️ Return the parser's warnings instead of printing them

0aef0e2 · cknitt + Claude · Nov 20, 2026, 22:07 UTC · edited

The parser printed its one warning, for the deprecated (. ...) syntax, through the compiler's warning reporting when it finished. It now keeps its warnings as values of a new type, Res_warning.t, and returns them with the parse result. The compiler reports them as before, right after parsing: Syntax_driver.report_warnings turns them into Warnings.Deprecated, called by bsc, res_parser, the playground and Res_multi_printer. Editor analysis, rescript-tools and the snippets the compiler parses for error hints no longer print the warning. A unit test checks the returned warnings.

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

✅ Compiler benchmarks

Allocated words

In total: 636,548,865 → 636,549,839 (±0.00%).

Generated projects: 629,013,942 → 629,016,287 (±0.00%).

None of the 265 benchmarks changed by 0.1% or more.

Instructions

In total: 9,222,455,744 → 9,222,593,747 (±0.00%).

Benchmark Base Head Change
parse/RedBlackTree.res 14,958,402 14,976,795 +0.12%

Output size

In total: 25,969,539 → 25,969,533 (±0.00%).

None of the 13 benchmarks changed by 0.1% or more.

Pull request 0aef0e2 compared with base 8103f0c in this run.

@codecov

codecov Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.19%. Comparing base (0ecb8d7) to head (0aef0e2).

Additional details and impacted files
@@                   Coverage Diff                    @@
##           parser-driver-to-common    #9363   +/-   ##
========================================================
  Coverage                    82.19%   82.19%           
========================================================
  Files                          461      462    +1     
  Lines                        65749    65761   +12     
========================================================
+ Hits                         54043    54055   +12     
  Misses                       11706    11706           
Files with missing lines Coverage Δ
compiler/bsc/rescript_compiler_driver.ml 80.91% <ø> (ø)
compiler/common/res_multi_printer.ml 75.00% <ø> (ø)
compiler/common/syntax_driver.ml 100.00% <100.00%> (ø)
compiler/syntax/cli/res_cli.ml 77.77% <100.00%> (-0.41%) ⬇️
compiler/syntax/src/res_core.ml 92.07% <100.00%> (ø)
compiler/syntax/src/res_driver.ml 97.87% <100.00%> (+0.31%) ⬆️
compiler/syntax/src/res_parser.ml 96.00% <100.00%> (-0.13%) ⬇️
compiler/syntax/src/res_warning.ml 100.00% <100.00%> (ø)
tests/ounit_tests/ounit_parser_cursor_tests.ml 99.11% <100.00%> (+0.02%) ⬆️
🚀 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 Nov 20, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

rescript

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

@rescript/belt

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

@rescript/darwin-arm64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/runtime

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

@rescript/win32-x64

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

commit: 0aef0e2

@cknitt

cknitt commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T07:55:15.164613Z 0aef0e2 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: 645cb8ba17

ℹ️ 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/syntax/src/res_driver.ml Resolved
Comment thread compiler/syntax/src/res_parser.ml Resolved
The parser printed its one warning, for the deprecated (. ...) syntax,
through the compiler's warning reporting when it finished. It now keeps its
warnings as values of a new type, Res_warning.t, and returns them with the
parse result. The compiler reports them as before, right after parsing:
Syntax_driver.report_warnings turns them into Warnings.Deprecated, called by
bsc, res_parser, the playground and Res_multi_printer. Editor analysis,
rescript-tools and the snippets the compiler parses for error hints no
longer print the warning. A unit test checks the returned warnings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QchYQ7itFLVLUmZ368okjH
Signed-off-by: Christoph Knittel <ck@cca.io>
@cknitt
cknitt force-pushed the parser-warnings-as-values branch from 645cb8b to 0aef0e2 Compare November 21, 2026 07:26
@cknitt cknitt removed the changelog:skip No release notes needed label Nov 21, 2026
@cknitt

cknitt commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 0aef0e2157

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

@cknitt
cknitt marked this pull request as ready for review November 21, 2026 07:56
@cknitt
cknitt merged commit 79aadce into master Nov 21, 2026
25 of 40 checks passed
@cknitt
cknitt deleted the parser-warnings-as-values branch November 21, 2026 10:16
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.

2 participants