Closed joaovam closed 3 weeks ago
Thanks for the report. I try to get to it, but am currently pretty busy with other things so can't promise anything timely. I am happy to review a PR that fixes it though.
[one-liner to reproduce]
bazel run -c dbg verilog/tools/syntax:verible-verilog-syntax -- - <<EOF
module m();
id_0var_0 (var_3), var_1, var_2;
endmodule
EOF
The problem seems to be happening in the rule for instantiation_base
:
instantiation_base
: instantiation_type non_anonymous_gate_instance_or_register_variable_list
{ $$ = MakeInstantiationBase($1, $2); }
| reference call_base ',' gate_instance_or_register_variable_list
{$$ = MakeInstantiationBase(ReinterpretReferenceAsDataTypePackedDimensions($1), ExtendNode($4,$3,$2)); }
| reference_or_call_base
{$$ = MakeTaggedNode(N::kFunctionCall,$1); }
;
The second case is matched due to the comma appearing after the call (id_0var_0 (var_3)
). ReinterpretReferenceAsDataTypePackedDimensions
will return a node with the kDataType
tag, but MakeInstantiationBase
expects a kInstantiationType
tag.
Why is this second case of the rule needed at all? I can't think of any situation where it would be needed for valid syntax. When I tried commenting it out, all of Verible's tests have passed and verible-verilog-syntax correctly identified the syntax error in the input given by @joaovam:
-:2:27: syntax error at token ","
Just briefly looking at this, I recall that we don't have great support for anonymous instances, and this second grammar case may have been a haklf-baked attempt to support a single declaration that mixes anonymous with named instances (I'm not even sure if this is valid).
So sounds like this faulty production might be good to comment out with a /* TODO: support mixed anonymous declarations */
with a reference to this bug why it was removed.
@rafasumi can you prepare a Pull Request ?
Might be worthwhile checking that running .github/bin/smoke-test.sh
has the same non-zero exit code counts for all verible-verilog-syntax
invocations.
@rafasumi can you prepare a Pull Request ?
Sure, I'll work on it!
The verible-verilog-syntax crashes when trying to analyze the following input:
the crash output is the following:
The expected behavior would be to exit the program, identifying a syntax error near id_0 without crashing.