Make filename-to-module-name derivation consistent across compiler and Rewatch
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Refactoring
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- javascript, ocaml
- Bereich
- build-system, compilers
Rechercherichtung
Start by tracing Ext_filename.module_name, Js_implementation.module_of_filename, Rewatch’s filename conversion, Ext_char.is_lower_case, and the generated JavaScript dependency filename logic. Compare their handling of ASCII, non-ASCII names, extensions, namespaces, paired .res/.resi files, and -o overrides. Done means the supported contract is explicit, all paths agree, and unsupported filenames receive consistent diagnostics with regression coverage.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Problem
Filename-to-module-name conversion currently follows different rules across the compiler, build system, and generated import paths.
- Implementation compilation uses
Ext_filename.module_name, which applies legacy Latin-1 byte capitalization throughExt_string.capitalize_ascii/capitalize_sub. - Interface compilation uses
Js_implementation.module_of_filename, which appliesString.capitalize_ascii. - Rewatch uses Unicode uppercasing of the first character.
.cmjfilename-case metadata usesExt_char.is_lower_case, with the same legacy Latin-1 byte ranges.- JavaScript dependency filenames are reconstructed with ASCII-only uncapitalization.
For ordinary ASCII filenames these rules agree. For non-ASCII input they can disagree or corrupt the module name.
Confirmed examples
| Filename stem | Implementation conversion | Interface conversion | Rewatch conversion |
|---|---|---|---|
foo |
Foo |
Foo |
Foo |
éclair |
éclair |
éclair |
Éclair |
ßeta |
ßeta |
ßeta |
SSeta |
中文 |
Invalid UTF-8 | Unchanged | Unchanged |
😀foo |
Invalid UTF-8 | Unchanged | Unchanged |
The invalid UTF-8 results occur because the legacy implementation subtracts 32 from the first byte, treating a UTF-8 leading byte as a Latin-1 lowercase character.
The compiler accepts these non-ASCII filenames without an early naming diagnostic. However, Éclair is not an ordinary ReScript module identifier, and quoting it does not make it valid in a module alias.
Ext_filename.as_module has ASCII-oriented validation, but the compilation paths above do not use it. Rewatch’s is_non_exotic_module_name filters generated namespace aliases rather than rejecting source filenames during discovery.
Why this matters
Inconsistent derivation can make the build graph disagree with compiler module identities. Inconsistent case metadata and filename reconstruction can also produce dependency imports that do not match emitted files.
Unicode uppercasing is not generally reversible: for example, ß becomes SS. A binary upper/lower case flag cannot recover the original filename from such a transformation.
Proposed direction
Define the supported filename-to-module-name contract explicitly and apply it consistently:
- Use ASCII-only capitalization for conventional module filenames.
- Decide how unsupported or exotic filenames should be handled, and report a clear diagnostic where appropriate.
- Share compiler derivation between implementations and interfaces, returning the module name and filename-case metadata together.
- Make Rewatch follow the same contract.
- Remove
Ext_charand the legacy Latin-1 capitalization once their responsibilities have been replaced.
Also reconcile extension stripping: interface derivation stops at the first dot, implementation derivation at the last dot, and Rewatch removes the final source extension. Any change must preserve intended handling of generated filenames.
Regression coverage
Cover lowercase/uppercase ASCII names, non-ASCII first and subsequent characters, Unicode case expansion, multiple dots, namespaces and namespace entries, paired .res/.resi files, and compiler output overrides (-o).
For supported names, verify that compiler identities, Rewatch dependency keys, emitted filenames, and generated imports agree. For unsupported names, verify consistent diagnostics before compilation artifacts are produced.
- Vorherrschende Sprache
- OCaml
- Sterne
- 7.5k
- Forks
- 485
- Ø Merge
- 21 Std. 51 Min.
- Gemergte PRs (30 T.)
- 53
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus rescript-lang/rescript
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 22/100
rescript-lang/rescript#8733 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
rescript-lang/rescript#8727 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Integer range patterns ending at 2147483647 generate incorrect JavaScriptEvtl. vergeben @fhammerschmidt hat das vor 5 Tagen übernommen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 70/100
rescript-lang/rescript#8716 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Integer range patterns on record fields match values below the rangeEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 76/100
rescript-lang/rescript#8713 ·
Maintainer antworten meist innerhalb von 1 Tag
-
A regex literal that starts a statement is parsed as division, and the formatter removes the parentheses that prevent itEvtl. vergeben @fhammerschmidt hat das vor 4 Tagen übernommen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 68/100
rescript-lang/rescript#8688 · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in rescript-lang/rescript
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
0x80/isolate-package#218 ·
-
libasr headers?Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
Maintainer antworten meist innerhalb von 1 Tag
-
qt6base报错Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
coolsnowwolf/lede#14208 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
yjh051108/dsh-routing-suite#194 ·