From 2a00fd38c2dbefecb08a7a78d8518173bc88f517 Mon Sep 17 00:00:00 2001 From: Lennard Sprong Date: Thu, 25 Sep 2025 12:01:15 +0200 Subject: [PATCH] Fix Frequency weight being affected by filters --- Sources/PropertyBased/Gen+Frequency.swift | 2 +- Sources/PropertyBased/Generator.swift | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Sources/PropertyBased/Gen+Frequency.swift b/Sources/PropertyBased/Gen+Frequency.swift index 604bcf3..39b210c 100644 --- a/Sources/PropertyBased/Gen+Frequency.swift +++ b/Sources/PropertyBased/Gen+Frequency.swift @@ -85,7 +85,7 @@ extension Gen { let pick = FloatLiteralType.random(in: 0.. pick }! as Int - return (index: index, value: options[index].gen._runIntermediate(&rng)) + return (index: index, value: options[index].gen.runFull(&rng).input) }, shrink: { pair in let opt = options[pair.index] diff --git a/Sources/PropertyBased/Generator.swift b/Sources/PropertyBased/Generator.swift index 7b34b26..959406f 100644 --- a/Sources/PropertyBased/Generator.swift +++ b/Sources/PropertyBased/Generator.swift @@ -34,9 +34,11 @@ public struct Generator: Send /// Run the generator until a single unfiltered value is found. @inlinable - internal func runFull(_ rng: inout G) -> sending ( - input: InputValue, result: ResultValue - ) { + internal func runFull(_ rng: inout G) + -> sending ( + input: InputValue, result: ResultValue + ) + { var arng: any SeededRandomNumberGenerator = rng defer { rng = arng as! G }