gdamore / tree-sitter-d

D Grammar for Tree Sitter
MIT License
41 stars 7 forks source link

Support if-statement expression being a variable definition #30

Closed nordlow closed 1 month ago

nordlow commented 5 months ago

Constructs such as

if (auto ID = EXPR) {
}

are currently not recognized.

gdamore commented 1 month ago

That's incorrect.

Here's a test case (and it passes current master):

================================================================================
If declaration as conditional
================================================================================

unittest {
    if (auto x = testit) { }
}
--------------------------------------------------------------------------------

(source_file
  (unittest_declaration
    (unittest)
    (block_statement
      (if_statement
        (if)
        (if_condition
          (auto)
          (identifier)
          (expression
            (identifier)))
        (scope_statement
          (block_statement))))))
gdamore commented 1 month ago

If you think this should be represented by some other grammar please provide information. Otherwise I'll close as not a bug.

nordlow commented 1 month ago

Ok, thanks at lot.