Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-primitive field option followed by any option cannot be parsed #49

Closed
bufdev opened this issue Jan 3, 2018 · 3 comments
Closed

Comments

@bufdev
Copy link
Contributor

bufdev commented Jan 3, 2018

func TestFieldCustomOptions(t *testing.T) {
	proto := `foo.bar lots = 1 [foo={hello:1}, bar=2];`
	p := newParserOn(proto)
	f := newNormalField()
	err := f.parse(p)
	if err != nil {
		t.Fatal(err)
	}
	if got, want := f.Type, "foo.bar"; got != want {
		t.Errorf("got [%v] want [%v]", got, want)
	}
	if got, want := f.Name, "lots"; got != want {
		t.Errorf("got [%v] want [%v]", got, want)
	}
	if got, want := len(f.Options), 2; got != want {
		t.Fatalf("got [%v] want [%v]", got, want)
	}
	if got, want := f.Options[0].Name, "foo"; got != want {
		t.Errorf("got [%v] want [%v]", got, want)
	}
	if got, want := f.Options[1].Name, "bar"; got != want {
		t.Errorf("got [%v] want [%v]", got, want)
	}
	if got, want := f.Options[1].Constant.Source, "2"; got != want {
		t.Errorf("got [%v] want [%v]", got, want)
	}
}

This returns:

<input>:1:37: found "=" but expected [option aggregate key colon :]

This fails if bar is a non-primitive as well. If foo is a primitive and bar is a non-primitive, this passes.

@bufdev
Copy link
Contributor Author

bufdev commented Jan 3, 2018

I think the problem is in Option.parseAggregate, see #50

@bufdev
Copy link
Contributor Author

bufdev commented Feb 27, 2018

Any update on this?

emicklei pushed a commit that referenced this issue Feb 27, 2018
@bufdev
Copy link
Contributor Author

bufdev commented Feb 27, 2018

Closing this, will re-open if needed. Thanks!

@bufdev bufdev closed this as completed Feb 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant