Repository navigation
Conversation
Changelog🐛 Bug fix
Semantic Diff1 commit · Full page Print
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9143 +/- ##
=======================================
Coverage 81.73% 81.74%
=======================================
Files 460 460
Lines 64936 64940 +4
=======================================
+ Hits 53076 53082 +6
+ Misses 11860 11858 -2
🚀 New features to boost your workflow:
|
rescript
@rescript/belt
@rescript/darwin-arm64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
|
Developer playground preview: https://rescript-lang.github.io/rescript/dev-playground/?version=pr-9143 |
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
859cef9 to
d2eb41e
Compare
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
d2eb41e to
70824bc
Compare
Why:
The printer wrote the @as name of a constructor with OCaml's %S and the
@as name of a field and the strings of an external with String.escaped.
Both turn non-ASCII bytes into decimal escapes such as \195\169, which
ReScript reads back as other characters: an interface written by
createInterface for an applied functor then gave its fields and
constructors other runtime names than the implementation (#9142).
They are now encoded with String_literal.encode_js_string, which keeps
valid UTF-8 and escapes only what a string literal needs.
Diagnostic modified (@as names of a constructor and a field):
Example:
module M: {
type t = | @as("é") A({@as("prénom") name: string}) | @as("a\"b") B
} = {
type t = | @as("é") A({@as("prénom") name: int}) | @as("a\"b") B
}
Before (diagnostic):
Actual declaration (as_names_printed_as_written.res:6:3-66):
type t = @as("\195\169") A({@as("pr\195\169nom") name: int}) | @as("a\"b") B
After (diagnostic):
Actual declaration (as_names_printed_as_written.res:6:3-66):
type t = @as("é") A({@as("prénom") name: int}) | @as("a\"b") B
Diagnostic modified (strings of an external):
Example:
module M: {
@module("ünïcode") @scope("ëxtra")
external f: int => int = "f"
} = {
@module("ünïcode") @scope("ëxtra")
external f: string => int = "f"
}
Before (diagnostic):
Actual declaration (external_strings_printed_as_written.res:6:3-7:33):
@Val @module("\195\188n\195\175code") @scope("\195\171xtra") external f: string => int = "f"
After (diagnostic):
Actual declaration (external_strings_printed_as_written.res:6:3-7:33):
@Val @module("ünïcode") @scope("ëxtra") external f: string => int = "f"
Format modified (createInterface for an applied functor):
Example:
module Make = (X: {type t}) => {
type record = {@as("prénom") name: X.t}
}
module Applied = Make({
type t = string
})
Before (rescript): the field is named "prénom" when the interface is read back
module Applied: {
type record = {@as("pr\195\169nom") name: string}
}
After (rescript):
module Applied: {
type record = {@as("prénom") name: string}
}
Fixes: #9142
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gLpf7RN1MiRcubPgRn
Signed-off-by: Christoph Knittel <ck@cca.io>
70824bc to
4676523
Compare
Fixes #9142.
The printer of declarations escaped strings the OCaml way:
%Sfor the@asname of a constructor,String.escapedfor the@asname of a field and for every string of a printed external (@module,@scope, inline string constants). Both write non-ASCII bytes as decimal escapes like\195\169, which ReScript reads back as other characters. A generated interface for an applied functor then named@as("prénom")asprénomat run time, and error messages and hover showed the escapes.The strings are now encoded with
String_literal.encode_js_string, which keeps valid UTF-8 and escapes only what a string literal needs, as #9136 does for@tagnames.New tests:
tests/build_tests/super_errors/fixtures/as_names_printed_as_written.res(constructor and field@aswith non-ASCII letters and a quote) andexternal_strings_printed_as_written.res(@moduleand@scopewith non-ASCII letters).🤖 Generated with Claude Code
https://claude.ai/code/session_01Kbf3gLpf7RN1MiRcubPgRn