tree-sitter-grammars / tree-sitter-zig

Zig grammar for tree-sitter
MIT License
6 stars 3 forks source link

bug: enum and untyped union fields parsed as types #4

Open xdBronch opened 3 days ago

xdBronch commented 3 days ago

Did you check existing issues?

Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)

No response

Describe the bug

title

Steps To Reproduce/Bad Parse Tree

const e = enum {
    a,
    b,
};
const uu = union(enum) {
    a,
    b: u32,
};

this gives

(variable_declaration 
  (identifier) 
  (enum_declaration 
    (container_field 
      type: (identifier)) 
    (container_field 
      type: (identifier)))) 
(variable_declaration 
  (identifier) 
  (union_declaration 
    (container_field 
      type: (identifier)) 
    (container_field 
      name: (identifier) 
      type: (builtin_type))))

both enum fields and the first union field are given type field names

Expected Behavior/Parse Tree

(variable_declaration 
  (identifier) 
  (enum_declaration 
    (container_field 
      name: (identifier)) 
    (container_field 
      name: (identifier)))) 
(variable_declaration 
  (identifier) 
  (union_declaration 
    (container_field 
      name: (identifier)) 
    (container_field 
      name: (identifier) 
      type: (builtin_type))))

all the fields should be name: (identifier)

Repro

No response

xdBronch commented 3 days ago

hm I think I can just work around this with wildcards, I'll leave this open for now but I'm fine with it being closed