Skip to content

Fix parsing type annotations starting with 'a in uncurried mode. #5822

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 17, 2022
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ These are only breaking changes for unformatted code.

#### :nail_care: Polish

- Syntax: process uncurried types explicitly in the parser/printer https://github.com/rescript-lang/rescript-compiler/pull/5784
- Syntax: process uncurried types explicitly in the parser/printer https://github.com/rescript-lang/rescript-compiler/pull/5784 https://github.com/rescript-lang/rescript-compiler/pull/5822
- Syntax: process uncurried function declarations explicitly in the parser/printer https://github.com/rescript-lang/rescript-compiler/pull/5794
- PPX V4: allow uncurried `make` function and treat it like a curried one [#5802](https://github.com/rescript-lang/rescript-compiler/pull/5802) [#5808](https://github.com/rescript-lang/rescript-compiler/pull/5808) [#5812](https://github.com/rescript-lang/rescript-compiler/pull/5812)

Expand Down
7 changes: 6 additions & 1 deletion lib/4.06.1/unstable/js_playground_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -166296,7 +166296,12 @@ and parsePolyTypeExpr p =
let typ = Ast_helper.Typ.var ~loc:var.loc var.txt in
let returnType = parseTypExpr ~alias:false p in
let loc = mkLoc typ.Parsetree.ptyp_loc.loc_start p.prevEndPos in
Ast_helper.Typ.arrow ~loc Asttypes.Nolabel typ returnType
let tFun = Ast_helper.Typ.arrow ~loc Asttypes.Nolabel typ returnType in
if p.uncurried_by_default then
Ast_helper.Typ.constr ~loc
{txt = Ldot (Ldot (Lident "Js", "Fn"), "arity1"); loc}
[tFun]
else tFun
| _ -> Ast_helper.Typ.var ~loc:var.loc var.txt)
| _ -> assert false)
| _ -> parseTypExpr p
Expand Down
7 changes: 6 additions & 1 deletion lib/4.06.1/whole_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -179728,7 +179728,12 @@ and parsePolyTypeExpr p =
let typ = Ast_helper.Typ.var ~loc:var.loc var.txt in
let returnType = parseTypExpr ~alias:false p in
let loc = mkLoc typ.Parsetree.ptyp_loc.loc_start p.prevEndPos in
Ast_helper.Typ.arrow ~loc Asttypes.Nolabel typ returnType
let tFun = Ast_helper.Typ.arrow ~loc Asttypes.Nolabel typ returnType in
if p.uncurried_by_default then
Ast_helper.Typ.constr ~loc
{txt = Ldot (Ldot (Lident "Js", "Fn"), "arity1"); loc}
[tFun]
else tFun
| _ -> Ast_helper.Typ.var ~loc:var.loc var.txt)
| _ -> assert false)
| _ -> parseTypExpr p
Expand Down
7 changes: 6 additions & 1 deletion res_syntax/src/res_core.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3909,7 +3909,12 @@ and parsePolyTypeExpr p =
let typ = Ast_helper.Typ.var ~loc:var.loc var.txt in
let returnType = parseTypExpr ~alias:false p in
let loc = mkLoc typ.Parsetree.ptyp_loc.loc_start p.prevEndPos in
Ast_helper.Typ.arrow ~loc Asttypes.Nolabel typ returnType
let tFun = Ast_helper.Typ.arrow ~loc Asttypes.Nolabel typ returnType in
if p.uncurried_by_default then
Ast_helper.Typ.constr ~loc
{txt = Ldot (Ldot (Lident "Js", "Fn"), "arity1"); loc}
[tFun]
else tFun
| _ -> Ast_helper.Typ.var ~loc:var.loc var.txt)
| _ -> assert false)
| _ -> parseTypExpr p
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ type upp = (. ()) => (. ()) => int
type uu2 = (. unit, unit) => unit
type up2 = (. (), ()) => unit

let uannpoly: (. 'a) => string = xx
let uannint: (. int) => string = xx

@@uncurried

let cApp = foo(. 3)
Expand Down Expand Up @@ -67,4 +70,7 @@ type upp = () => () => int
type uu2 = (unit, unit) => unit
type up2 = ((), ()) => unit

let pipe1 = 3->f
let pipe1 = 3->f

let uannpoly: 'a => string = xx
let uannint: int => string = xx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ type nonrec uup = (unit -> int Js.Fn.arity0) Js.Fn.arity1
type nonrec upp = int Js.Fn.arity0 Js.Fn.arity0
type nonrec uu2 = (unit -> unit -> unit) Js.Fn.arity2
type nonrec up2 = (unit -> unit -> unit) Js.Fn.arity2
let (uannpoly : ('a -> string) Js.Fn.arity1) = xx
let (uannint : (int -> string) Js.Fn.arity1) = xx
[@@@uncurried ]
let cApp = foo 3
let uApp = ((foo 3)[@bs ])
Expand Down Expand Up @@ -84,4 +86,6 @@ type nonrec uup = (unit -> int Js.Fn.arity0) Js.Fn.arity1
type nonrec upp = int Js.Fn.arity0 Js.Fn.arity0
type nonrec uu2 = (unit -> unit -> unit) Js.Fn.arity2
type nonrec up2 = (unit -> unit -> unit) Js.Fn.arity2
let pipe1 = 3 |.u f
let pipe1 = 3 |.u f
let (uannpoly : ('a -> string) Js.Fn.arity1) = xx
let (uannint : (int -> string) Js.Fn.arity1) = xx