Close #1035 Fix :> / :< generators producing values that violate the schema - #1301
Open
vssekorin wants to merge 1 commit into
Open
Close #1035 Fix :> / :< generators producing values that violate the schema#1301vssekorin wants to merge 1 commit into
:> / :< generators producing values that violate the schema#1301vssekorin wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1035.
Problem
[:> x]turned the exclusive bound into an inclusive one with(inc x)and handed it togen/double*as:min.incdoes not move a double once|x| >= 2^53, so the generator was asked for values>= xand producedxitself:The reported
Double/MAX_VALUEcase is just the extreme end of it — the bug starts at2^53::<had the mirror problem via(dec x), and additionally threw on[:< (- Double/MAX_VALUE)](Couldn't satisfy such-that predicate after 10 tries).Fix
src/malli/generator.cljc-next-up— the next representable double abovex.Math/nextUpon the JVM; in ClojureScript, where no such function exists, one arithmetic ulp step (overshooting a representable value or two is harmless for generation).gen-double-above— generator of doubles strictly greater thanx, covering the three edges:##NaNor##Inf→ unreachable generator (-never-gen);##-Inf→ the plain double generator;Double/MAX_VALUEonly##Infis left →(gen/return ##Inf).:>now delegates togen-double-above;:<is:>negated, which removes the duplicated mirror logic and fixes[:< (- Double/MAX_VALUE)]along the way.