Skip to content

Commit 97812a7

Browse files
committed
Keep original var names
1 parent 5611b52 commit 97812a7

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

compiler/ml/translcore.ml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,12 @@ and transl_stdlib_option_call exp opt_expr info oargs =
10741074
match oargs with
10751075
| (Nolabel, Some _) :: (Nolabel, Some _) :: _ | (Nolabel, Some _) :: [] ->
10761076
let opt_lam = transl_exp opt_expr in
1077-
let opt_id = Ident.create "__res_option_opt" in
1077+
let opt_id =
1078+
match info.callback with
1079+
| Stdlib_option_inline_lambda {param; _} ->
1080+
Ident.create (Ident.name param)
1081+
| _ -> Ident.create "__res_option_value"
1082+
in
10781083
let opt_var = Lvar opt_id in
10791084
let callback_result =
10801085
bind_option_value ~payload_not_nested:info.payload_not_nested opt_var

tests/tests/src/core/Core_ObjectTests.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,8 @@ runGetTest({
531531
]
532532
}),
533533
get: i => {
534-
let __res_option_opt = i["a"];
535-
return Stdlib_Option.getOr(__res_option_opt !== undefined ? __res_option_opt.concat([
534+
let i$1 = i["a"];
535+
return Stdlib_Option.getOr(i$1 !== undefined ? i$1.concat([
536536
4,
537537
5
538538
]) : undefined, []);

tests/tests/src/core/intl/Core_IntlTests.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ try {
5757
let e$2 = Primitive_exceptions.internalToException(raw_e$2);
5858
if (e$2.RE_EXN_ID === "JsExn") {
5959
let e$3 = e$2._1;
60-
let __res_option_opt = Stdlib_JsExn.message(e$3);
61-
let message = __res_option_opt !== undefined ? __res_option_opt.toLowerCase() : undefined;
60+
let __res_option_value = Stdlib_JsExn.message(e$3);
61+
let message = __res_option_value !== undefined ? __res_option_value.toLowerCase() : undefined;
6262
let exit = 0;
6363
if (message === "invalid key : someinvalidkey") {
6464
console.log("Caught expected error");

tests/tests/src/option_stdlib_optimization_test.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import * as Belt_MapString from "@rescript/runtime/lib/es6/Belt_MapString.js";
77
import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
88

99
function getIncidentCategoryName(incidents, categories, incidentId) {
10-
let __res_option_opt = incidentId !== undefined ? Belt_MapString.get(incidents, incidentId) : undefined;
11-
let __res_option_opt$1 = __res_option_opt !== undefined ? __res_option_opt.categoryId : undefined;
12-
let __res_option_opt$2 = __res_option_opt$1 !== undefined ? Belt_MapString.get(categories, __res_option_opt$1) : undefined;
13-
if (__res_option_opt$2 !== undefined) {
14-
return __res_option_opt$2.name;
10+
let incident = incidentId !== undefined ? Belt_MapString.get(incidents, incidentId) : undefined;
11+
let categoryId = incident !== undefined ? incident.categoryId : undefined;
12+
let category = categoryId !== undefined ? Belt_MapString.get(categories, categoryId) : undefined;
13+
if (category !== undefined) {
14+
return category.name;
1515
}
1616

1717
}

0 commit comments

Comments
 (0)