Repository navigation
Commit 0800cb4
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
Claude-Session: https://claude.ai/code/session_01Kbf3gLpf7RN1MiRcubPgRn
Signed-off-by: Christoph Knittel <ck@cca.io>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 8e26a9c commit 0800cb4
7 files changed
Lines changed: 67 additions & 3 deletions
File tree
- changes
- compiler
- ml
- syntax/src
- tests/build_tests/super_errors
- expected
- fixtures
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
945 | 945 | | |
946 | 946 | | |
947 | 947 | | |
948 | | - | |
| 948 | + | |
| 949 | + | |
949 | 950 | | |
950 | 951 | | |
951 | 952 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
44 | 47 | | |
45 | 48 | | |
46 | 49 | | |
| |||
394 | 397 | | |
395 | 398 | | |
396 | 399 | | |
397 | | - | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
398 | 406 | | |
399 | 407 | | |
400 | 408 | | |
| |||
450 | 458 | | |
451 | 459 | | |
452 | 460 | | |
453 | | - | |
454 | 461 | | |
455 | 462 | | |
456 | 463 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
0 commit comments