Skip to content

Commit c062551

Browse files
committed
Fix issue with async context and locally abstract types
This is a port of the compiler part of #5982 to 10.1.
1 parent cd0fa20 commit c062551

File tree

7 files changed

+30
-13
lines changed

7 files changed

+30
-13
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
- Fix issue where error messages related to non-existent props were displayed without location information https://github.com/rescript-lang/syntax/pull/730
2121
- Fix issue where uncurried functions were incorrectly converting the type of a prop given as a default value to curried https://github.com/rescript-lang/syntax/pull/731
2222
- Fix issue with nested async functions, where the inner function would be emitted without `async` https://github.com/rescript-lang/rescript-compiler/pull/5984
23+
- Fix issue with printing async functions with locally abstract types https://github.com/rescript-lang/syntax/pull/732
24+
- Fix issue with async context and locally abstract types.
2325

2426
# 10.1.2
2527

jscomp/frontend/bs_builtin_ppx.ml

+5
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ let expr_mapper ~async_context ~in_function_def (self : mapper)
115115
| true, pexp_attributes ->
116116
Ast_bs_open.convertBsErrorFunction e.pexp_loc self pexp_attributes
117117
cases)
118+
| Pexp_newtype (s, body) ->
119+
let async = Ast_attributes.has_async_payload e.pexp_attributes <> None in
120+
let body = Ast_async.add_async_attribute ~async body in
121+
let res = self.expr self body in
122+
{e with pexp_desc = Pexp_newtype(s, res)}
118123
| Pexp_fun (label, _, pat, body) -> (
119124
let async = Ast_attributes.has_async_payload e.pexp_attributes <> None in
120125
match Ast_attributes.process_attributes_rev e.pexp_attributes with

jscomp/napkin/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
- Fix an issue where error messages related to duplicate props were displayed without a loc and were unclear https://github.com/rescript-lang/syntax/pull/728
5959
- Fix issue where error messages related to non-existent props were displayed without location information https://github.com/rescript-lang/syntax/pull/730
6060
- Fix issue where uncurried functions were incorrectly converting the type of a prop given as a default value to curried https://github.com/rescript-lang/syntax/pull/731
61+
- Fix issue with printing async functions with locally abstract types https://github.com/rescript-lang/syntax/pull/732
6162

6263
#### :eyeglasses: Spec Compliance
6364

lib/4.06.1/unstable/js_compiler.ml

+7-4
Original file line numberDiff line numberDiff line change
@@ -49739,10 +49739,8 @@ let funExpr expr =
4973949739
| expr -> (attrsBefore, List.rev acc, expr)
4974049740
in
4974149741
match expr with
49742-
| {
49743-
pexp_desc = Pexp_fun (_, _defaultExpr, _pattern, _returnExpr);
49744-
pexp_attributes = attrs;
49745-
} as expr ->
49742+
| {pexp_desc = Pexp_fun _ | Pexp_newtype _; pexp_attributes = attrs} as expr
49743+
->
4974649744
collect attrs [] {expr with pexp_attributes = []}
4974749745
| expr -> collect [] [] expr
4974849746

@@ -272986,6 +272984,11 @@ let expr_mapper ~async_context ~in_function_def (self : mapper)
272986272984
| true, pexp_attributes ->
272987272985
Ast_bs_open.convertBsErrorFunction e.pexp_loc self pexp_attributes
272988272986
cases)
272987+
| Pexp_newtype (s, body) ->
272988+
let async = Ast_attributes.has_async_payload e.pexp_attributes <> None in
272989+
let body = Ast_async.add_async_attribute ~async body in
272990+
let res = self.expr self body in
272991+
{e with pexp_desc = Pexp_newtype(s, res)}
272989272992
| Pexp_fun (label, _, pat, body) -> (
272990272993
let async = Ast_attributes.has_async_payload e.pexp_attributes <> None in
272991272994
match Ast_attributes.process_attributes_rev e.pexp_attributes with

lib/4.06.1/unstable/js_playground_compiler.ml

+7-4
Original file line numberDiff line numberDiff line change
@@ -49739,10 +49739,8 @@ let funExpr expr =
4973949739
| expr -> (attrsBefore, List.rev acc, expr)
4974049740
in
4974149741
match expr with
49742-
| {
49743-
pexp_desc = Pexp_fun (_, _defaultExpr, _pattern, _returnExpr);
49744-
pexp_attributes = attrs;
49745-
} as expr ->
49742+
| {pexp_desc = Pexp_fun _ | Pexp_newtype _; pexp_attributes = attrs} as expr
49743+
->
4974649744
collect attrs [] {expr with pexp_attributes = []}
4974749745
| expr -> collect [] [] expr
4974849746

@@ -272986,6 +272984,11 @@ let expr_mapper ~async_context ~in_function_def (self : mapper)
272986272984
| true, pexp_attributes ->
272987272985
Ast_bs_open.convertBsErrorFunction e.pexp_loc self pexp_attributes
272988272986
cases)
272987+
| Pexp_newtype (s, body) ->
272988+
let async = Ast_attributes.has_async_payload e.pexp_attributes <> None in
272989+
let body = Ast_async.add_async_attribute ~async body in
272990+
let res = self.expr self body in
272991+
{e with pexp_desc = Pexp_newtype(s, res)}
272989272992
| Pexp_fun (label, _, pat, body) -> (
272990272993
let async = Ast_attributes.has_async_payload e.pexp_attributes <> None in
272991272994
match Ast_attributes.process_attributes_rev e.pexp_attributes with

lib/4.06.1/whole_compiler.ml

+7-4
Original file line numberDiff line numberDiff line change
@@ -225711,10 +225711,8 @@ let funExpr expr =
225711225711
| expr -> (attrsBefore, List.rev acc, expr)
225712225712
in
225713225713
match expr with
225714-
| {
225715-
pexp_desc = Pexp_fun (_, _defaultExpr, _pattern, _returnExpr);
225716-
pexp_attributes = attrs;
225717-
} as expr ->
225714+
| {pexp_desc = Pexp_fun _ | Pexp_newtype _; pexp_attributes = attrs} as expr
225715+
->
225718225716
collect attrs [] {expr with pexp_attributes = []}
225719225717
| expr -> collect [] [] expr
225720225718

@@ -283370,6 +283368,11 @@ let expr_mapper ~async_context ~in_function_def (self : mapper)
283370283368
| true, pexp_attributes ->
283371283369
Ast_bs_open.convertBsErrorFunction e.pexp_loc self pexp_attributes
283372283370
cases)
283371+
| Pexp_newtype (s, body) ->
283372+
let async = Ast_attributes.has_async_payload e.pexp_attributes <> None in
283373+
let body = Ast_async.add_async_attribute ~async body in
283374+
let res = self.expr self body in
283375+
{e with pexp_desc = Pexp_newtype(s, res)}
283373283376
| Pexp_fun (label, _, pat, body) -> (
283374283377
let async = Ast_attributes.has_async_payload e.pexp_attributes <> None in
283375283378
match Ast_attributes.process_attributes_rev e.pexp_attributes with

0 commit comments

Comments
 (0)