eval icon indicating copy to clipboard operation
eval copied to clipboard

Incorrect evaluation order when using data-like access

Open ekse opened this issue 6 years ago • 1 comments

Evaluation order seems to be wrong when the dot operator is used.

    #[test]
    fn test_operator_precedence() {
        // Show that operator precedence is working as expected.
        assert_eq!(eval(r#""a" == "a" && "b" == "b""#), Ok(to_value(true)));
        
        let mut v = HashMap::new();
        v.insert("a", "1");
        v.insert("b", "2");
        
        // This is returning the expected result if we put the comparisons between parentheses.
        assert_eq!(Expr::new("(v.a == v.a) && (v.b == v.b)").value("v", v.clone()).exec(), 
            Ok(to_value(true)));

        // This should return the same result as the previous Expr, but it is instead 
        // returning Err(UnsupportedTypes("String(\"1\")", "Bool(true)")).
        assert_eq!(Expr::new("v.a == v.a && v.b == v.b").value("v", v).exec(), 
            Ok(to_value(true)));
    }

ekse avatar Jan 18 '19 20:01 ekse

Sorry guys. I have no time and interest in Rust right now. This project is going to Abandoned status.

fengcen avatar Jan 19 '19 01:01 fengcen