Skip to content

Backport upstream parser changes about function arity #2401

@Julow

Description

@Julow

ocaml/ocaml#12236 has been merged in ocaml and contains changes to the parsetree.
The changes are helping the work on the CST (#2213).

This requires some more changes: (thanks @ncik-roberts for the heads up)

  • fun x -> fun y -> must no longer be rewritten to fun x y ->, as the two have different semantics.
  • fun x -> function y -> x + y is also different from fun x -> (function y -> x + y). so parens around function are now meaningful.

@ncik-roberts adds:

In the case where the programmer writes fun x -> fun y -> x + y, it might be nice to visually exaggerate the fact that the inner function is separate now, with something like fun x -> (fun y -> x + y). (Now that this PR is merged, fun x -> fun y -> x + y has different runtime characteristics than fun x y -> x + y, where the former is an arity-1 function returning an arity-1 function, and the latter is an arity-2 function.)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions