tree-sitter / tree-sitter-haskell

Haskell grammar for tree-sitter.
MIT License
151 stars 36 forks source link

Misparse of explicit-braced code #92

Closed lf- closed 3 months ago

lf- commented 1 year ago

I was reading some GHC sources when I found my highlighting was broken.

Here's a minimized example (which does compile with GHC):

module OhNo where
lookupIdInScope :: Monad m => m ()
lookupIdInScope
  = do { case () of
           () -> do { return () } }
  where
    blah = ()

AST:

module: module [0, 7] - [0, 11]
where [0, 12] - [0, 17]
ERROR [1, 0] - [6, 13]
  pat_typed [1, 0] - [2, 15]
    pattern: pat_name [1, 0] - [1, 15]
      variable [1, 0] - [1, 15]
    type: context [1, 19] - [2, 15]
      constraint [1, 19] - [1, 26]
        class: class_name [1, 19] - [1, 24]
          type [1, 19] - [1, 24]
        type_name [1, 25] - [1, 26]
          type_variable [1, 25] - [1, 26]
      type_apply [1, 30] - [2, 15]
        type_name [1, 30] - [1, 31]
          type_variable [1, 30] - [1, 31]
        type_literal [1, 32] - [1, 34]
          con_unit [1, 32] - [1, 34]
        type_name [2, 0] - [2, 15]
          type_variable [2, 0] - [2, 15]
  exp_literal [3, 14] - [3, 16]
    con_unit [3, 14] - [3, 16]
  alt [4, 11] - [4, 33]
    pat_literal [4, 11] - [4, 13]
      con_unit [4, 11] - [4, 13]
    exp_do [4, 17] - [4, 33]
      stmt [4, 22] - [4, 31]
        exp_apply [4, 22] - [4, 31]
          exp_name [4, 22] - [4, 28]
            variable [4, 22] - [4, 28]
          exp_literal [4, 29] - [4, 31]
            con_unit [4, 29] - [4, 31]
  ERROR [4, 34] - [6, 10]
  pat_literal [6, 11] - [6, 13]
    con_unit [6, 11] - [6, 13]