GithubHelp home page GithubHelp logo

Comments (9)

AltSysrq avatar AltSysrq commented on July 30, 2024 1

I just hit a related case

Fixed in 0.8.6, along with some other issues with subsequence.

The original issue this report is about no longer happens as of 0.8.6 since Range is now used as the internal representation (in exchange for simply not allowing usize::MAX to be an included value at all).

from proptest.

AltSysrq avatar AltSysrq commented on July 30, 2024

I doubt anyone is actually using this or will do so in the near future since proptest doesn't ever return this type on its own, so it would require someone else to decide to use SizeRange themselves and then go back into a range. I agree it should be removed eventually, but I'm inclined to wait for the next breaking changes train.

from proptest.

Centril avatar Centril commented on July 30, 2024

I agree it should be removed eventually, but I'm inclined to wait for the next breaking changes train.

Yeah; I agree with everything you said and this :)

I would suggest that we start with a more elaborate labeling system in this repo with milestones and more labels, which will be more important as proptest grows in importance in the ecosystem (which I'm hoping it will, because I think it is the state of the art wrt. Rust and testing). Something like:

  • E-easy
  • E-medium
  • E-hard
  • E-help-wanted
  • P-high
  • P-low
  • breaking-change

and so on...

Here's some inspiration:

from proptest.

Eh2406 avatar Eh2406 commented on July 30, 2024

I just hit a related case, subsequence(s, 0) panics subtracted with overflow do to:

/// Given `low .. high`, then a size range `[low, high)` is the result.
impl From<Range<usize>> for SizeRange {
    fn from(r: Range<usize>) -> Self { size_range(r.start..=r.end - 1) }
}

(note that the 0 is generated from a separate part of the strategy, not a hardcoded value I could easily change.)

from proptest.

Centril avatar Centril commented on July 30, 2024

Seems I implemented that incorrectly; should be:

/// Given `low .. high`, then a size range `[low, high)` is the result.
impl From<Range<usize>> for SizeRange {
    fn from(r: Range<usize>) -> Self {
        let end = if r.end == 0 { 0 } else { r.end - 1 };
        size_range(r.start..=end)
    }
}

This can only occur if you provide forall x: usize. (x..0).

EDIT: actually... probably not; this would change the semantics given 0..0.
You can't translate that to 0..=0 which would happen if we changed the implementation to that.

EDIT: To actually represent the concept of an empty range in RangeInclusive I think you'd need to define this as (x+1)..x. Maybe SizeRange should be defined as struct SizeRange(Option<RangeInclusive<usize>>) instead...?

EDIT: but if you do that... you can't convert SizeRange to RangeInclusive<usize> anymore... sigh :/

from proptest.

Eh2406 avatar Eh2406 commented on July 30, 2024

Or you can use saturating_sub, in fact that could be a good mitigation or this entire thing.

from proptest.

Centril avatar Centril commented on July 30, 2024

@Eh2406 if you do r.start..=r.end.saturating_sub(1) then you may still reach cases like 0..0 becoming 0..=0 which is now 1 element more.

from proptest.

AltSysrq avatar AltSysrq commented on July 30, 2024

(I'm going to keep this open for the moment since there are some other unaddressed talking points still.)

from proptest.

AltSysrq avatar AltSysrq commented on July 30, 2024

Removed the impls in question in 0.9.0.

from proptest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.