tree-sitter-grammars / tree-sitter-hcl

HCL grammar for tree-sitter
https://tree-sitter-grammars.github.io/tree-sitter-hcl/
Apache License 2.0
92 stars 20 forks source link

Compile warning with missing-field-initializers #18

Closed Xuanwo closed 2 years ago

Xuanwo commented 2 years ago

Describe the bug

I'm trying to integrate tree-sitter-hcl with difftastic

But meeting the following compile warning:

warning: vendor/tree-sitter-hcl-src/scanner.cc: In member function ‘bool {anonymous}::Scanner::scan(TSLexer*, const bool*)’:
warning: vendor/tree-sitter-hcl-src/scanner.cc:99:39: warning: missing initializer for member ‘{anonymous}::Context::heredoc_identifier’ [-Wmissing-field-initializers]
warning:    99 |       Context ctx = { QUOTED_TEMPLATE };
warning:       |                                       ^
warning: vendor/tree-sitter-hcl-src/scanner.cc:117:48: warning: missing initializer for member ‘{anonymous}::Context::heredoc_identifier’ [-Wmissing-field-initializers]
warning:   117 |         Context ctx = { TEMPLATE_INTERPOLATION };
warning:       |                                                ^
warning: vendor/tree-sitter-hcl-src/scanner.cc:145:44: warning: missing initializer for member ‘{anonymous}::Context::heredoc_identifier’ [-Wmissing-field-initializers]
warning:   145 |         Context ctx = { TEMPLATE_DIRECTIVE };
warning:       |                                            ^

To Reproduce Steps to reproduce the behavior:

  1. Build with clang

Expected behavior No warning

Screenshots image


I'm glad to send a PR if fixing the warning looks good to you :smile:

MichaHoffmann commented 2 years ago

Hey @Xuanwo,

Thanks for pointing this out! Yeah, please go ahead with a PR, that would be cool.

We probably should add -Werror here to make sure to catch that in the CI: https://github.com/MichaHoffmann/tree-sitter-hcl/blob/d559c46ba170808b23a73da0cf49f315d221d095/.github/workflows/build.yaml#L22

Xuanwo commented 2 years ago

Thanks for the quick response!

I will fix it ASAP.