Skip to content

#565 Conclude#follow raises Fbe::Error on second call#572

Merged
yegor256 merged 2 commits into
zerocracy:masterfrom
VasilevNStas:565-conclude-follow-guard
Jul 7, 2026
Merged

#565 Conclude#follow raises Fbe::Error on second call#572
yegor256 merged 2 commits into
zerocracy:masterfrom
VasilevNStas:565-conclude-follow-guard

Conversation

@VasilevNStas

Copy link
Copy Markdown
Contributor

Fixes #565

Conclude#follow now raises Fbe::Error when called a second time, consistent with by and as in Fbe::Iterate.

Previously it silently overwrote @follows.

@VasilevNStas

Copy link
Copy Markdown
Contributor Author

@yegor256 please review

@morphqdd morphqdd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implements #565follow now raises instead of silently overwriting on a second call, matching by. I checked @follows is initialized to [] in the constructor, so the first call's @follows.empty? is safe. One gap inline.

Comment thread lib/fbe/conclude.rb
# @param [Array<String>] props List of property names
# @return [nil] Nothing
def follow(props)
raise(Fbe::Error, 'Follow is already set') unless @follows.empty?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This behavior change ships without a test. Since #565 is specifically about the second call, a test that calls follow twice and asserts the second raises Fbe::Error (and that a single call still works) would lock in the new contract.

@VasilevNStas

Copy link
Copy Markdown
Contributor Author

Good catch. Added test_follow_raises_on_second_call — calls follow twice inside a conclude block and asserts the second raises Fbe::Error. Single-call path continues to work (verified by existing test_follow_multivalued).

@0crat

0crat commented Jul 7, 2026

Copy link
Copy Markdown

@morphqdd Thanks for the review! You've earned +9 points for this: +18 as a basis; -5 for very few (1) comments; -4 for too few (1) hits-of-code. Your running score is +698; don't forget to check your Zerocracy account too).

@yegor256 yegor256 merged commit e245abb into zerocracy:master Jul 7, 2026
10 checks passed
@0crat

0crat commented Jul 7, 2026

Copy link
Copy Markdown

@VasilevNStas Thanks for the contribution! You've earned +20 points for this: +24 as a basis; -4 for too few (22) hits-of-code. Please, keep them coming. Your running score is +2000; don't forget to check your Zerocracy account too).

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.

Fbe::Conclude#follow silently overwrites on second call, unlike by and as which raise Fbe::Error

4 participants