Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit dec285c

Browse files
author
Iwan
committed
Fix printing of @send and @inline attributes
Fixes #292 Prints `@bs.send` as `@send` and `@bs.inline` as `@inline` Followup of #230
1 parent 7ff315d commit dec285c

File tree

6 files changed

+43
-2
lines changed

6 files changed

+43
-2
lines changed

src/res_ast_conversion.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ let normalize =
341341
| "bs.module" -> "module"
342342
| "bs.scope" -> "scope"
343343
| "bs.splice" | "bs.variadic" -> "variadic"
344+
| "bs.send" -> "send"
344345
| "bs.set" -> "set"
345346
| "bs.set_index" -> "set_index"
346347
| "bs.get" -> "get"
@@ -354,6 +355,7 @@ let normalize =
354355
| "bs.deriving" -> "deriving"
355356
| "bs.string" -> "string"
356357
| "bs.int" -> "int"
358+
| "bs.inline" -> "inline"
357359
| "bs.ignore" -> "ignore"
358360
| "bs.unwrap" -> "unwrap"
359361
| "bs.as" -> "as"

src/res_printer.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4813,6 +4813,7 @@ and printAttribute ((id, payload) : Parsetree.attribute) cmtTbl =
48134813
| "bs.module" -> "module"
48144814
| "bs.scope" -> "scope"
48154815
| "bs.splice" | "bs.variadic" -> "variadic"
4816+
| "bs.send" -> "send"
48164817
| "bs.set" -> "set"
48174818
| "bs.set_index" -> "set_index"
48184819
| "bs.get" -> "get"
@@ -4826,6 +4827,7 @@ and printAttribute ((id, payload) : Parsetree.attribute) cmtTbl =
48264827
| "bs.deriving" -> "deriving"
48274828
| "bs.string" -> "string"
48284829
| "bs.int" -> "int"
4830+
| "bs.inline" -> "inline"
48294831
| "bs.ignore" -> "ignore"
48304832
| "bs.unwrap" -> "unwrap"
48314833
| "bs.as" -> "as"

tests/conversion/reason/__snapshots__/render.spec.js.snap

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`attributes.re 1`] = `
4+
"module Color: {
5+
type t = private string
6+
7+
@inline(\\"red\\") let red: t
8+
@inline(\\"black\\") let black: t
9+
} = {
10+
type t = string
11+
12+
@inline let red = \\"red\\"
13+
@inline let black = \\"black\\"
14+
}
15+
16+
@send external map: (array<'a>, 'a => 'b) => array<'b> = \\"map\\"
17+
@send external filter: (array<'a>, 'a => 'b) => array<'b> = \\"filter\\"
18+
list{1, 2, 3}->map(a => a + 1)->filter(a => modulo(a, 2) == 0)->Js.log
19+
"
20+
`;
21+
322
exports[`bracedJsx.re 1`] = `
423
"open Belt
524

tests/conversion/reason/attributes.re

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module Color: {
2+
type t = pri string;
3+
4+
[@bs.inline "red"] let red: t;
5+
[@bs.inline "black"] let black: t;
6+
} = {
7+
type t = string;
8+
9+
[@bs.inline] let red = "red";
10+
[@bs.inline] let black = "black";
11+
};
12+
13+
[@bs.send] external map: (array('a), 'a => 'b) => array('b) = "map";
14+
[@bs.send] external filter: (array('a), 'a => 'b) => array('b) = "filter";
15+
[1, 2, 3]
16+
->map(a => a + 1)
17+
->filter(a => modulo(a, 2) == 0)
18+
->Js.log;

tests/printer/structure/__snapshots__/render.spec.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ include (
117117
{
118118
@val @module(\\"react\\")
119119
external createElementInternalHack: 'a = \\"createElement\\"
120-
@bs.send
120+
@send
121121
external apply: (
122122
'theFunction,
123123
'theContext,

tests/printer/structure/include.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ include (
88
{
99
@val @module("react")
1010
external createElementInternalHack: 'a = "createElement"
11-
@bs.send
11+
@send
1212
external apply: (
1313
'theFunction,
1414
'theContext,

0 commit comments

Comments
 (0)