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

Fix printing of @send and @inline attributes #293

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/res_ast_conversion.ml
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ let normalize =
| "bs.module" -> "module"
| "bs.scope" -> "scope"
| "bs.splice" | "bs.variadic" -> "variadic"
| "bs.send" -> "send"
| "bs.set" -> "set"
| "bs.set_index" -> "set_index"
| "bs.get" -> "get"
Expand All @@ -354,6 +355,7 @@ let normalize =
| "bs.deriving" -> "deriving"
| "bs.string" -> "string"
| "bs.int" -> "int"
| "bs.inline" -> "inline"
| "bs.ignore" -> "ignore"
| "bs.unwrap" -> "unwrap"
| "bs.as" -> "as"
Expand Down
2 changes: 2 additions & 0 deletions src/res_printer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4813,6 +4813,7 @@ and printAttribute ((id, payload) : Parsetree.attribute) cmtTbl =
| "bs.module" -> "module"
| "bs.scope" -> "scope"
| "bs.splice" | "bs.variadic" -> "variadic"
| "bs.send" -> "send"
| "bs.set" -> "set"
| "bs.set_index" -> "set_index"
| "bs.get" -> "get"
Expand All @@ -4826,6 +4827,7 @@ and printAttribute ((id, payload) : Parsetree.attribute) cmtTbl =
| "bs.deriving" -> "deriving"
| "bs.string" -> "string"
| "bs.int" -> "int"
| "bs.inline" -> "inline"
| "bs.ignore" -> "ignore"
| "bs.unwrap" -> "unwrap"
| "bs.as" -> "as"
Expand Down
19 changes: 19 additions & 0 deletions tests/conversion/reason/__snapshots__/render.spec.js.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`attributes.re 1`] = `
"module Color: {
type t = private string

@inline(\\"red\\") let red: t
@inline(\\"black\\") let black: t
} = {
type t = string

@inline let red = \\"red\\"
@inline let black = \\"black\\"
}

@send external map: (array<'a>, 'a => 'b) => array<'b> = \\"map\\"
@send external filter: (array<'a>, 'a => 'b) => array<'b> = \\"filter\\"
list{1, 2, 3}->map(a => a + 1)->filter(a => modulo(a, 2) == 0)->Js.log
"
`;

exports[`bracedJsx.re 1`] = `
"open Belt

Expand Down
18 changes: 18 additions & 0 deletions tests/conversion/reason/attributes.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module Color: {
type t = pri string;

[@bs.inline "red"] let red: t;
[@bs.inline "black"] let black: t;
} = {
type t = string;

[@bs.inline] let red = "red";
[@bs.inline] let black = "black";
};

[@bs.send] external map: (array('a), 'a => 'b) => array('b) = "map";
[@bs.send] external filter: (array('a), 'a => 'b) => array('b) = "filter";
[1, 2, 3]
->map(a => a + 1)
->filter(a => modulo(a, 2) == 0)
->Js.log;
2 changes: 1 addition & 1 deletion tests/printer/structure/__snapshots__/render.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ include (
{
@val @module(\\"react\\")
external createElementInternalHack: 'a = \\"createElement\\"
@bs.send
@send
external apply: (
'theFunction,
'theContext,
Expand Down
2 changes: 1 addition & 1 deletion tests/printer/structure/include.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include (
{
@val @module("react")
external createElementInternalHack: 'a = "createElement"
@bs.send
@send
external apply: (
'theFunction,
'theContext,
Expand Down