bufbuild/protocompile

Panic in NewMessageFieldNode

Alfus opened this issue · 0 comments

Parsing this example, causes a panic in ast.NewMessageFieldNode:

syntax = "proto3";

package buf.lsp.test.v1;

import "buf/validate/validate.proto";

message TestMessage {
  TestNestedEnum test_nested_enum = 3 [(buf.validate.field) = {
    enum: {
      defined_only: true,
      not_in: [1,]
    }
  }];
}

enum TestEnum {
  TEST_ENUM_UNSPECIFIED = 0;
  TEST_ENUM_FOO = 1;
  TEST_ENUM_BAR = 1;
}

The stack trace is:

panic: val is nil

goroutine 26 [running]:
github.com/bufbuild/protocompile/ast.NewMessageFieldNode(0x1400010ee60, 0x140001274d0, {0x0, 0x0})
	/Users/alfred/go/pkg/mod/github.com/bufbuild/protocompile@v0.6.0/ast/values.go:541 +0x394
github.com/bufbuild/protocompile/parser.(*protoParserImpl).Parse(0x14000375000, {0x103559cd0, 0x14000051bc0})
	/Users/alfred/go/pkg/mod/github.com/bufbuild/protocompile@v0.6.0/parser/proto.y.go:1506 +0x56d4
github.com/bufbuild/protocompile/parser.protoParse({0x103559cd0, 0x14000051bc0})
	/Users/alfred/go/pkg/mod/github.com/bufbuild/protocompile@v0.6.0/parser/proto.y.go:966 +0x54
github.com/bufbuild/protocompile/parser.Parse({0x0, 0x0}, {0x103556b80, 0x1400041f580}, 0x140003fa6c0)
	/Users/alfred/go/pkg/mod/github.com/bufbuild/protocompile@v0.6.0/parser/parser.go:98 +0xd0
...

Ideally a ignorable error would be produced instead.