Giter VIP home page Giter VIP logo

Comments (3)

 avatar commented on August 13, 2024

Placing braces around exception specification alleviates the problem somewhat, still a proper solution would be nice.

from tuareg.

monnier avatar monnier commented on August 13, 2024

The patch below should add support for that new syntax.

diff --git a/tuareg.el b/tuareg.el
index 9bd6d95..ed20b64 100644
--- a/tuareg.el
+++ b/tuareg.el
@@ -1272,7 +1272,10 @@ by |, insert one |."
               (iddef (id "f=" exp1))
               (branches (branches "|" branches) (branch))
               (branch (patterns "->" exp1))
-              (patterns (pattern) (pattern "when" exp1))
+              (patterns (pattern) (pattern "when" exp1)
+                        ;; Since OCaml 4.02, `match' expressions allow
+                        ;; `exception' branches.
+                        ("exception-case" pattern))
               (pattern (id) (pattern "as" id) (pattern "," pattern))
               (class-body (class-body "inherit" class-body)
                           (class-body "method" class-body)
@@ -1452,7 +1455,8 @@ of the token."
         (goto-char (match-end 0))
         (match-string 0)))
      ((or (member tok '("let" "=" "->"
-                        "module" "class" "open" "type" "with" "and"))
+                        "module" "class" "open" "type" "with" "and"
+                        "exception"))
           ;; http://caml.inria.fr/pub/docs/manual-ocaml/expr.html lists
           ;; the tokens whose precedence is based on their prefix.
           (memq (aref tok 0) '(?* ?/ ?% ?+ ?- ?@ ?^ ?= ?< ?> ?| ?& ?$)))
@@ -1610,6 +1614,9 @@ Return values can be
             "label:"
           (goto-char pos)
           tok)))
+     ((equal tok "exception")
+      (if (save-excursion (equal (tuareg-smie--backward-token) "|"))
+          "exception-case" tok))
      ((string-match "\\`[[:alpha:]_].*\\.\\'"  tok)
       (forward-char (1- (length tok))) ".")
      (t tok))))

from tuareg.

Chris00 avatar Chris00 commented on August 13, 2024

@roysc The Tuareg version at the time of this comment indents your code as

let f =
  let n =
    match List.find ((=) 3) [1;2] with
    | x -> x
    | exception Not_found -> 0
  in n

so I think we can consider this fixed.

from tuareg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.