You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d0dba1f
Browse filesBrowse the repository at this point in the historyBrowse files
Reject bindings of a module that get the same JavaScript name (rescript-lang#8982)
Why:
`Ext_ident.convert` maps both `delete` and `$$delete` to `$$delete`,
and `\"a-b"` like `a$b`, so two bindings could share an export name or
a module object key: the ES export list repeated a name, which Node
rejects, and CommonJS output and nested modules lost a binding. The
type checker now rejects such a module, at the second binding. This
replaces Lam_coercion's "is exported twice" check, which only covered
equal source names and had no location.
Diagnostic added (JavaScript name clash):
Example:
let delete = 1
let $$delete = 2
Before (js):
let $$delete = 1;
let $$delete$1 = 2;
export {
$$delete,
$$delete$1 as $$delete,
}
After (diagnostic):
This value has the same JavaScript name $$delete
as the value at A.res:1:5-10.
Rename one of them.
Diagnostic modified (exception and module of one name):
Example:
exception M(int)
module M = {
let x = 3
}
Before (diagnostic): M is exported twice
After (diagnostic):
This module has the same JavaScript name M
as the extension constructor at A.res:1:1-16.
Rename one of them.
Review: Why not rename one of the two exports? Importers derive an export's name from the source name alone (`js_export_name`), so a renamed export would not be found by them; the clash has to be resolved in the source.
Review: Which signatures are checked? Each structure's signature and each written signature (module types and `.resi` files), since every module block is built from one of them. The exports of a compilation unit keep `default` as written, so only nested modules reject `default` beside `$$default`.
Claude-Session: https://claude.ai/code/session_01Xk6AeCYpCK4SZRtHYKHGoe
Signed-off-by: Christoph Knittel <ck@cca.io>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Pedro Castro <aspeddro@gmail.com>
- Report an error when two bindings of a module get the same JavaScript name, such as `delete` and `$$delete`, instead of emitting a duplicate or overwritten export.
0 commit comments