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

Callback with sequences break in refmt #2798

Closed
davesnx opened this issue Aug 27, 2024 · 0 comments · Fixed by #2799
Closed

Callback with sequences break in refmt #2798

davesnx opened this issue Aug 27, 2024 · 0 comments · Fixed by #2799
Labels
KIND: BUG Printer things that have to do with turning an AST into Reason code

Comments

@davesnx
Copy link
Member

davesnx commented Aug 27, 2024

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

@davesnx davesnx added KIND: BUG Printer things that have to do with turning an AST into Reason code labels Aug 27, 2024
@reasonml reasonml deleted a comment Aug 27, 2024
@reasonml reasonml deleted a comment Aug 27, 2024
@reasonml reasonml deleted a comment from GoldenCaterpie Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
KIND: BUG Printer things that have to do with turning an AST into Reason code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant