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

Tags on rules that can yield more than one pair #982

Closed
tomtau opened this issue Feb 20, 2024 Discussed in #979 · 0 comments · Fixed by #985
Closed

Tags on rules that can yield more than one pair #982

tomtau opened this issue Feb 20, 2024 Discussed in #979 · 0 comments · Fixed by #985

Comments

@tomtau
Copy link
Contributor

tomtau commented Feb 20, 2024

Discussed in #979

Originally posted by agatti February 15, 2024
Hi there!

I'm using pest for the very first time and I'm not sure if I bumped into a bug or not. So, given this grammar fragment on the latest stable version (2.7.7 with "grammar-extras"):

tag = {
	// stuff here
}

container = {
	// stuff here
	"{" ~ #tags=tag* ~ "}"
	// more stuff here
}

I'd assume that calling find_tagged("tags") on a Pair<Rule::container> would return all the Pair<Rule::tag> that are between brackets. However what I see is that find_tagged returns only the last tag seen by the parser, as if there's just one available pair per tag and it gets overwritten as the parser goes through data. The grammar seems to be correct as if I remove the #tags= bit and do the inner pair iteration myself all the tags are there.

I've read the pest book and I couldn't find anything saying there are limitations on tags attached to rules that may yield more than a pair. Is this a bug, an undocumented limitation, or am I doing things wrong somewhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant