Skip to content

Word signature mismatch errors in ReScript terms - #9078

Merged
cknitt merged 1 commit into
fix-error-type-indentationfrom
fix-9066-inclusion-error-wording
Oct 28, 2026
Merged

cknitt merged 1 commit into
fix-error-type-indentationfrom
fix-9066-inclusion-error-wording

Conversation

@cknitt

@cknitt cknitt commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Fixes #9066. Stacked on #9091.

Signature mismatch errors now:

  • call variant constructors constructors instead of fields ("The types for constructor Str are not equal", and the arity, name and missing-constructor variants);
  • write functor positions in ReScript syntax (At position module F: (X) => <here> instead of module F(X) : <here>);
  • quote names with backticks on both sides (The value `b` is required);
  • print type t += A with one space.

New fixtures: gadt_constructor_signature_mismatch, functor_signature_mismatch.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Kbf3gLMawVgtmiKy3TMBc3

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Changelog

💅 Polish

  • Multi-line types, signatures and module types in error messages are indented under their heading instead of starting at column 0.
  • Signature mismatch errors name variant constructors as constructors, write functor positions and quotes in ReScript syntax, and print type t += A with a single space.

Semantic Diff

2 commits · Full page

✏️ Indent multi-line types and signatures in error messages

cbcd4f6 · Christoph Knittel + Claude · Oct 27, 2026, 19:53 UTC · edited

The outcome printer rendered a type, signature or module type to a string and handed it to Format as one piece, so every line after the first started at column 0 instead of under its heading, and a short multi-line signature could share a line with the text around it. Each line break is now a newline of the enclosing Format box, and a multi-line piece makes that box break around it.

Diagnostic modified (module mismatch)

module type S = {
  type t
}
module M: {
  module F: (X: S) => S with type t = X.t
} = {
  module F = (X: S) => {
    type t = int
  }
}

diagnostic · Before

Modules do not match:
  {
module F: (X: S) => {
  type t = int
}

}

is not included in
…
Modules do not match: {
type t = int

} is not included in {

type t = X.t

}

diagnostic · After

Modules do not match:
  {
    module F: (X: S) => {
      type t = int
    }
  }
is not included in
…
Modules do not match:
  {
    type t = int
  }
is not included in
  {
    type t = X.t
  }

Part of #9074.

Review

  • Which messages change? Every one that prints a multi-line type, signature or module type, mostly signature mismatches; their snapshots change only in layout.
  • Does this change single-line types in messages? No. A doc that fits on one line is printed as before; only the line breaks of multi-line ones are emitted differently.
Word signature mismatch errors in ReScript terms

1db203e · cknitt + Claude · Oct 27, 2026, 12:41 UTC

Why

Inclusion errors still used OCaml wording: variant constructors were called fields, functor positions were written as module F(X) : ..., names were quoted as x', and extension constructors were printed with two spaces after +=`.

Diagnostic modified (variant constructor mismatch)

module M: {
  type rec t<_> = Int(int): t<int> | Str(string): t<string>
} = {
  type rec t<_> = Int(int): t<int> | Str(string): t<int>
}

diagnostic

-The types for field Str are not equal.
+The types for constructor Str are not equal.

Diagnostic modified (functor position)

module type S = {
  type t
}
module M: {
  module F: (X: S) => S with type t = X.t
} = {
  module F = (X: S) => {
    type t = int
  }
}

diagnostic

-At position module F(X) : <here>
+At position module F: (X) => <here>

Diagnostic modified (missing value)

diagnostic

-The value `b' is required but not provided
+The value `b` is required but not provided

Diagnostic modified (extension constructor)

diagnostic

-type t +=  Boom(string)
+type t += Boom(string)

Review

  • Do record fields keep their wording? Yes. Only the comparison of variant constructors uses the new constructor errors; inline record fields of a constructor are still compared as fields.

@codecov

codecov Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 65.00000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.45%. Comparing base (cbcd4f6) to head (1db203e).

Files with missing lines Patch % Lines
compiler/ml/includecore.ml 62.50% 6 Missing ⚠️
compiler/ml/includemod.ml 66.66% 1 Missing ⚠️
Additional details and impacted files
@@                      Coverage Diff                       @@
##           fix-error-type-indentation    #9078      +/-   ##
==============================================================
+ Coverage                       81.43%   81.45%   +0.01%     
==============================================================
  Files                             460      460              
  Lines                           64634    64639       +5     
==============================================================
+ Hits                            52633    52649      +16     
+ Misses                          12001    11990      -11     
Files with missing lines Coverage Δ
compiler/syntax/src/res_outcome_printer.ml 82.15% <100.00%> (+0.44%) ⬆️
compiler/ml/includemod.ml 77.92% <66.66%> (+2.03%) ⬆️
compiler/ml/includecore.ml 78.81% <62.50%> (-0.83%) ⬇️

... and 1 file with indirect coverage changes

🚀 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 27, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

rescript

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

@rescript/belt

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

@rescript/darwin-arm64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/runtime

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

@rescript/win32-x64

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

commit: 1db203e

@github-actions

Copy link
Copy Markdown

@cknitt
cknitt marked this pull request as ready for review October 27, 2026 14:20
@cknitt

cknitt commented Oct 27, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 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-27T14:42:52.536753Z d7661d5 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. 🚀

Reviewed commit: 14be98364d

ℹ️ 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 commented Oct 27, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: d7661d553e

ℹ️ 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 requested a review from cristianoc October 27, 2026 19:49
Why:
    Inclusion errors still used OCaml wording: variant constructors were
    called fields, functor positions were written as `module F(X) : ...`,
    names were quoted as `x', and extension constructors were printed
    with two spaces after `+=`.

Diagnostic modified (variant constructor mismatch):
Example:
    module M: {
      type rec t<_> = Int(int): t<int> | Str(string): t<string>
    } = {
      type rec t<_> = Int(int): t<int> | Str(string): t<int>
    }
Before (diagnostic):
    The types for field Str are not equal.
After (diagnostic):
    The types for constructor Str are not equal.

Diagnostic modified (functor position):
Example:
    module type S = {
      type t
    }
    module M: {
      module F: (X: S) => S with type t = X.t
    } = {
      module F = (X: S) => {
        type t = int
      }
    }
Before (diagnostic):
    At position module F(X) : <here>
After (diagnostic):
    At position module F: (X) => <here>

Diagnostic modified (missing value):
Before (diagnostic):
    The value `b' is required but not provided
After (diagnostic):
    The value `b` is required but not provided

Diagnostic modified (extension constructor):
Before (diagnostic):
    type t +=  Boom(string)
After (diagnostic):
    type t += Boom(string)

Review: Do record fields keep their wording?
    Yes. Only the comparison of variant constructors uses the new
    constructor errors; inline record fields of a constructor are still
    compared as fields.

Fixes: #9066
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gLMawVgtmiKy3TMBc3
Signed-off-by: Christoph Knittel <ck@cca.io>
@cknitt
cknitt force-pushed the fix-9066-inclusion-error-wording branch from d7661d5 to 1db203e Compare October 27, 2026 19:55
@cknitt
cknitt changed the base branch from master to fix-error-type-indentation October 27, 2026 19:55
@cknitt
cknitt added this pull request to stack #9092 October 27, 2026 19:55
@cknitt

cknitt commented Oct 27, 2026

Copy link
Copy Markdown
Member Author

The indentation fix for multi-line types and signatures moved to #9091, and this PR is now stacked on it; this branch was rebuilt on top of #9091 with only the wording commit.

@cristianoc cristianoc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed the wording-only delta on top of #9091, including constructor versus record-field errors, functor context rendering, and the new GADT/functor mismatch fixtures. No blocking issues found. CI checks inspected; tests were not rerun locally.

@cknitt
cknitt merged commit b7fed40 into master Oct 28, 2026
26 of 39 checks passed
@cknitt
cknitt deleted the fix-9066-inclusion-error-wording branch October 28, 2026 07:29
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.

Signature mismatch errors use OCaml wording

2 participants