math icon indicating copy to clipboard operation
math copied to clipboard

PolyOverZ::from_str accepts anything after the last coefficient is entered

Open Marvin-Beckmann opened this issue 3 years ago • 2 comments

          Why does this work?

Why is it possible to init a PolyOverZ with a string that contains mod?

Originally posted by @MoogSven in https://github.com/qfall/math/pull/255#discussion_r1211919509

Marvin-Beckmann avatar May 31 '23 19:05 Marvin-Beckmann

Here are some tests with which the problem can be reproduced

    /// Ensure that anything entered after the last coefficient results in an error
    #[test]
    fn information_beyond_last_coeff() {
        assert!(PolyOverZ::from_str("2  24 1 15").is_err());
        assert!(PolyOverZ::from_str("2  24 1 mod 15").is_err());
        assert!(PolyOverZ::from_str("2  24 1 something else").is_err());
    }

The Main Issue

Everything after the last coefficient is simply ignored by FLINT. The question is: Go for efficiency -> not check beforehand or go the safe round and preprocess the string?

Marvin-Beckmann avatar May 31 '23 19:05 Marvin-Beckmann

As of right now we have decided to leave it as it is for the sake of efficiency as this would require a post or preprocessing of every string.

Marvin-Beckmann avatar Sep 15 '23 15:09 Marvin-Beckmann