Skip to content

Callback with sequences break in refmt  #2798

@davesnx

Description

@davesnx

In unstable from melange's playground, it breaks code missing { } when a function has a sequence:

onEvent "/echo" (fun request ->
    let request_stream = get_body_stream request in
    stream
      ~headers:[ ("Content-Type", "application/octet-stream") ]
      (fun response_stream -> Js.log response_stream))

refmt generates

onEvent("/echo", request =>
  let request_stream = get_body_stream(request);
  stream(
    ~headers=[("Content-Type", "application/octet-stream")], response_stream =>
    Js.log(response_stream)
  );
);

correct version

onEvent("/echo", request => {
  let request_stream = get_body_stream(request);
  stream(
    ~headers=[("Content-Type", "application/octet-stream")], response_stream =>
    Js.log(response_stream)
  );
});

https://melange.re/unstable/playground/?language=OCaml&code=b25FdmVudCAiL2VjaG8iIChmdW4gcmVxdWVzdCAtPgogICAgbGV0IHJlcXVlc3Rfc3RyZWFtID0gZ2V0X2JvZHlfc3RyZWFtIHJlcXVlc3QgaW4KICAgIHN0cmVhbQogICAgICB%2BaGVhZGVyczpbICgiQ29udGVudC1UeXBlIiwgImFwcGxpY2F0aW9uL29jdGV0LXN0cmVhbSIpIF0KICAgICAgKGZ1biByZXNwb25zZV9zdHJlYW0gLT4gSnMubG9nIHJlc3BvbnNlX3N0cmVhbSkpCg%3D%3D&live=on

Metadata

Metadata

Assignees

No one assigned

    Labels

    KIND: BUGPrinterthings that have to do with turning an AST into Reason code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions