Skip to content
This repository was archived by the owner on Sep 26, 2020. It is now read-only.
This repository was archived by the owner on Sep 26, 2020. It is now read-only.

Incorrect evaluation order when using data-like access #5

@ekse

Description

@ekse

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)));
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions