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

#Iterate could check that segment shouldn't repeat #126

Closed
kputnam opened this issue May 8, 2018 · 0 comments
Closed

#Iterate could check that segment shouldn't repeat #126

kputnam opened this issue May 8, 2018 · 0 comments

Comments

@kputnam
Copy link
Owner

kputnam commented May 8, 2018

There's a small issue that I think enough people have encountered (probably not realizing it), that it would be helpful to beginners if it was fixed: foo.iterate(:XYZ) doesn't actually check that XYZ is a repeating segment.

If XYZ is not repeating (according to the grammar), then in cases where it finds XYZ the first time, it will throw an exception at the end of the given block when it tries to do another find -- "XYZ cannot be reached from this state". That's a confusing error because it appears that did find XYZ!

In the other case is that it didn't find XYZ, it doesn't throw an exception that you shouldn't have used iterate... it's kind of a bug waiting to happen when you eventually have a file that did have an XYZ.

I think we could change the definition of iterate by adding a test at the start, before calling find. This seems like a small change that would be good for a contributor to work on, and I think there's some code already (somewhere?) that checks if a segment is repeatable and throws an error if it's not... try searching for repeatable?. It might be in the Guide Builder code.

irobayna added a commit that referenced this issue Dec 8, 2018
Throw exception from #iterate if segment is not repeatable (fix #126)
irobayna added a commit that referenced this issue Jan 13, 2019
Fix repeatability test in Navigation#iterate (#126)
kputnam added a commit that referenced this issue Feb 12, 2019
specs for IdentifierStack and fix a bug; Change Navigation#elementn to
strictly validate its arguments, even when corresponding data is not
present; Fix validation in Navigation#iterate (#126); Write many more
specs
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