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

Fix parsing of poly-var typexpr consisting of one tag-spec-first #254

Merged
merged 3 commits into from
Feb 2, 2021
Merged
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Unreleased

* Implement new syntax for guards on pattern match cases in [3248](https://github.com/rescript-lang/syntax/pull/248)
* Fix parsing of poly-var typexpr consisting of one tag-spec-first in [254](https://github.com/rescript-lang/syntax/pull/254)
* Implement new syntax for guards on pattern match cases in [#248](https://github.com/rescript-lang/syntax/pull/248)
* Implement intelligent breaking for poly-var type expressions in [#246](https://github.com/rescript-lang/syntax/pull/246)
* Improve indentation of fast pipe chain in let binding in [#244](https://github.com/rescript-lang/syntax/pull/244)
* Improve printing of non-callback arguments in call expressions with callback in [#241](https://github.com/rescript-lang/syntax/pull/241/files)
Expand Down
10 changes: 8 additions & 2 deletions src/res_core.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4827,8 +4827,14 @@ and parseTagSpecFirst p =
[parsePolymorphicVariantTypeSpecHash ~attrs ~full:false p]
| _ ->
let typ = parseTypExpr ~attrs p in
Parser.expect Bar p;
[Parsetree.Rinherit typ; parseTagSpec p]
begin match p.token with
| Rbracket ->
(* example: [ListStyleType.t] *)
[Parsetree.Rinherit typ;]
| _ ->
Parser.expect Bar p;
[Parsetree.Rinherit typ; parseTagSpec p]
end

and parsePolymorphicVariantTypeSpecHash ~attrs ~full p : Parsetree.row_field =
let startPos = p.Parser.startPos in
Expand Down
16 changes: 16 additions & 0 deletions tests/idempotency/bs-css/Css.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
include Css_Legacy_Core;
include Css_Colors;

include Css_Legacy_Core.Make({
exception NotImplemented;

let make = (. _) => raise(NotImplemented);
let mergeStyles = (. _) => raise(NotImplemented);
let injectRule = (. _) => ();
let injectRaw = (. _) => ();
let makeKeyFrames = (. _) => raise(NotImplemented);
});

external unsafeJsonToStyles: Js.Json.t => ReactDOMRe.Style.t = "%identity";

let style = rules => rules->toJson->unsafeJsonToStyles;
37 changes: 37 additions & 0 deletions tests/idempotency/bs-css/CssEmotion.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
include Css_Legacy_Core;
include Css_Colors;

include Css_Legacy_Core.Make({
[@bs.module "emotion"]
external mergeStyles: (. array(string)) => string = "cx";

[@bs.module "emotion"] external make: (. Js.Json.t) => string = "css";

[@bs.module "emotion"]
external injectRule: (. Js.Json.t) => unit = "injectGlobal";

[@bs.module "emotion"]
external injectRaw: (. string) => unit = "injectGlobal";

[@bs.module "emotion"]
external makeKeyFrames: (. Js.Dict.t(Js.Json.t)) => string = "keyframes";
});

type cache;

[@bs.module "emotion"] external cache: cache = "cache";

let fontFace =
(~fontFamily, ~src, ~fontStyle=?, ~fontWeight=?, ~fontDisplay=?, ()) => {
let asString =
Css_Legacy_Core.fontFace(
~fontFamily,
~src,
~fontStyle?,
~fontWeight?,
~fontDisplay?,
(),
);
insertRule(asString);
fontFamily;
};
37 changes: 37 additions & 0 deletions tests/idempotency/bs-css/CssEmotionJs.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
include Css_Js_Core;
include Css_Colors;

include Css_Js_Core.Make({
[@bs.module "emotion"]
external mergeStyles: (. array(string)) => string = "cx";

[@bs.module "emotion"] external make: (. Js.Json.t) => string = "css";

[@bs.module "emotion"]
external injectRule: (. Js.Json.t) => unit = "injectGlobal";

[@bs.module "emotion"]
external injectRaw: (. string) => unit = "injectGlobal";

[@bs.module "emotion"]
external makeKeyFrames: (. Js.Dict.t(Js.Json.t)) => string = "keyframes";
});

type cache;

[@bs.module "emotion"] external cache: cache = "cache";

let fontFace =
(~fontFamily, ~src, ~fontStyle=?, ~fontWeight=?, ~fontDisplay=?, ()) => {
insertRule(.
Css_Js_Core.fontFace(
~fontFamily,
~src,
~fontStyle?,
~fontWeight?,
~fontDisplay?,
(),
),
);
fontFamily;
};
16 changes: 16 additions & 0 deletions tests/idempotency/bs-css/CssJs.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
include Css_Js_Core;
include Css_Colors;

include Css_Js_Core.Make({
exception NotImplemented;

let make = (. _) => raise(NotImplemented);
let mergeStyles = (. _) => raise(NotImplemented);
let injectRule = (. _) => ();
let injectRaw = (. _) => ();
let makeKeyFrames = (. _) => raise(NotImplemented);
});

external unsafeJsonToStyles: Js.Json.t => ReactDOMRe.Style.t = "%identity";

let style = (. rules) => rules->toJson->unsafeJsonToStyles;
Loading