Skip to content

Commit c527775

Browse files
committed
Fix %external extension.
Fixes #7270
1 parent 9de8f34 commit c527775

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#### :bug: Bug fix
2020

2121
- Fix async context checking for module await. https://github.com/rescript-lang/rescript/pull/7271
22+
- Fix `%external` extension. https://github.com/rescript-lang/rescript/pull/7272
2223

2324
# 12.0.0-alpha.8
2425

compiler/frontend/ast_exp_handle_external.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ let handle_external loc (x : string) : Parsetree.expression =
6060
Ast_compatible.app1 ~loc undefined_typeof
6161
(Exp.ifthenelse ~loc
6262
(Ast_compatible.app2 ~loc
63-
(Exp.ident ~loc {loc; txt = Ldot (Lident "Pervasives", "=")})
63+
(Exp.ident ~loc {loc; txt = Lident "=="})
6464
(Ast_compatible.app1 ~loc typeof raw_exp)
6565
(Ast_compatible.const_exp_string ~loc "undefined"))
6666
empty (Some raw_exp))

tests/tests/src/ExternalExtension.mjs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Generated by ReScript, PLEASE EDIT WITH CARE
2+
3+
4+
let match = typeof __DEV__ === "undefined" ? undefined : __DEV__;
5+
6+
if (match !== undefined) {
7+
console.log("dev mode");
8+
} else {
9+
console.log("production mode");
10+
}
11+
12+
/* match Not a pure module */

tests/tests/src/ExternalExtension.res

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
switch %external(__DEV__) {
2+
| Some(_) => Console.log("dev mode")
3+
| None => Console.log("production mode")
4+
}

0 commit comments

Comments
 (0)