reasonml / reasonml/reason

"/" still needs to be escaped in custom operators

Open
#2,420 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
OCaml
Stars
10.3k
Forks
438
PR merge metrics
No merged PRs in 30d

Description

Looks like I'm hitting the same issue, as discussed in #609. Cross-posting my comments from that closed issue:

Looks like there are stil issues with operators with / inside. The following code snippet is formatted from OCaml and results in syntax error (try link), until I escape (use <\/> operator instead):

let routes =
  Routes.(
    Infix.(
      Handlers.(
        with_method([
          (`GET, return_bigstring <$ empty),
          (`GET, greeter <$> s("greet") *> int </> str </> str),
          (`GET, sum <$> s("sum") *> int (</>) int),
        ])
      )
    )
  );

What's even worse, refmt removes those escapings, making the code unparseable again.

dune version: 1.10.0
esy version: 0.5.6
refmt version: Reason 3.3.7 @ 43efc14

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied Reason snippet and the reported refmt version, reproducing the syntax error and the formatter's removal of the escaping. Trace how custom operators containing / are parsed and formatted; done means the example parses successfully and refmt preserves valid escaping.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.