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

Fix type body parsing w.r.t. optional body types #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

amtelekom
Copy link
Contributor

The PatternStmt substatement is so generic, it also matches on other substatements.
Checking if it matches last works around this problem, although there might be a more robust solution.

@sjtakada
Copy link
Owner

@amtelekom Can you provide any example of pattern substatement which causes the problem?

@amtelekom amtelekom force-pushed the fix_leafref_body_parsing branch from b969378 to 9cc12c8 Compare July 11, 2022 08:08
@amtelekom amtelekom changed the title Fix leafref body parsing Fix type body parsing w.r.t. optional body types Jul 11, 2022
@amtelekom
Copy link
Contributor Author

amtelekom commented Jul 11, 2022

Hi,

I've since come across more problems with parsing type bodies, so more investigation & this more robust fix were needed.

The problem was that many type bodies have only optional parameters. Since collect_vec_stmt can parse any substatements into an empty PatternStmt, because all its substatments are optional,
if let Ok(pattern) = collect_nonempty_vec_stmt!(stmts, PatternStmt) always triggered. This made many types get assigned the wrong type-body.

To fix it, I've introduced a new version of collect_vec_stmt, collect_nonempty_vec_stmt, that will only return Ok if at least one substmt was able to be added to the vec.

I've also added 2 testcases from ietf yang files that fail against current main, but work with this fix.

@amtelekom amtelekom force-pushed the fix_leafref_body_parsing branch 2 times, most recently from b1e6537 to 37ad8ac Compare July 11, 2022 08:54
@amtelekom amtelekom force-pushed the fix_leafref_body_parsing branch from 37ad8ac to 0398e6b Compare July 11, 2022 08:54
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

Successfully merging this pull request may close these issues.

2 participants