Skip to content
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

Fix parsing of partial application with pipe #6325

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
4 changes: 2 additions & 2 deletions jscomp/syntax/src/res_core.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3604,15 +3604,15 @@ and parseCallExpr p funExpr =
in
let isPartial =
match p.token with
| DotDotDot when args <> [] ->
| DotDotDot ->
Copy link
Contributor Author

@glennsl glennsl Jul 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason for this restriction beyond the fact that f(...) can simple be reduced to f (if not piped)? Is it safe to remove it?

Parser.next p;
true
| _ -> false
in
Parser.expect Rparen p;
let args =
match args with
| [] ->
| [] when not isPartial ->
let loc = mkLoc startPos p.prevEndPos in
(* No args -> unit sugar: `foo()` *)
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,6 @@ type arrowPath4 = (. I.t) => string
type callback1 = ReactEvent.Mouse.t => unit as 'callback
type callback2 = ReactEvent.Mouse.t => (unit as 'u)
type callback3 = (ReactEvent.Mouse.t => unit) as 'callback

let partialPipe = x->f(...)
let partialPipe2 = x->f(y, ...)
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,6 @@ type nonrec callback1 =
type nonrec callback2 =
(ReactEvent.Mouse.t -> unit as 'u, [ `Has_arity1 ]) function$
type nonrec callback3 =
(ReactEvent.Mouse.t -> unit, [ `Has_arity1 ]) function$ as 'callback
(ReactEvent.Mouse.t -> unit, [ `Has_arity1 ]) function$ as 'callback
let partialPipe = x |.u f
let partialPipe2 = x |.u ((f y)[@res.partial ][@res.uapp ])
5 changes: 5 additions & 0 deletions jscomp/test/UncurriedExternals.res
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,8 @@ external useState: (@uncurry (unit => 'state)) => ('state, ('state => 'state) =>
let (get, set) = useState(() => 3)

let methodWithAsyncU = @this this => async arg => this + arg

let partialPipe: int => int = {
let f = (a, b) => a + b
2->f(...)
}
Loading