Function: neocaml--check-grammar-compatibility

neocaml--check-grammar-compatibility is a natively compiled function defined in neocaml.el.

Signature

(neocaml--check-grammar-compatibility)

Documentation

Check that installed grammars are compatible with this version of neocaml.

Emit a warning if an outdated grammar is detected.

Source Code

;; Defined in /nix/store/ahssdx4rwzyxhyhavpn0bkznk13xrggi-emacs-packages-deps/share/emacs/site-lisp/elpa/neocaml-20260907.2015/neocaml.el
(defun neocaml--check-grammar-compatibility ()
  "Check that installed grammars are compatible with this version of neocaml.
Emit a warning if an outdated grammar is detected."
  (unless neocaml--grammar-compatibility-checked
    (setq neocaml--grammar-compatibility-checked t)
    (when (treesit-language-available-p 'ocaml)
      ;; In v0.25.0, the type_binding "equation" field was renamed to
      ;; "body".  We parse a snippet and check whether the old field name
      ;; still exists.  treesit-query-compile doesn't validate field
      ;; names, so we must check against an actual parse tree.
      (with-temp-buffer
        (insert "type t = int")
        (let* ((parser (treesit-parser-create 'ocaml))
               (root (treesit-parser-root-node parser))
               (node (treesit-search-subtree root "type_binding")))
          (when (and node (treesit-node-child-by-field-name node "equation"))
            (display-warning
             'neocaml
             "The installed tree-sitter OCaml grammar appears older than the \
version required by neocaml.  Run C-u M-x neocaml-install-grammars to \
reinstall.")))))))