Compiling or() in DSL 'when' clause emits bad JS #50

Closed
goodwithgit opened this Issue Aug 21, 2013 · 0 comments

Comments

Projects
None yet
2 participants
@goodwithgit

I have a rule expressed in the DSL as follows:

rule beta {
    when {
        or(
           v1 : Value v1.id == 'hello',
           v2 : Value v2.id == 'goodbye'
           );
        r : Result
    }
    then {
        r.v.push("result"));
    }
}

Compiling (w. v0.1.8) the above yields the following JS (relevant excerpt):

                    }, ["or", , [Value, "v1", "v1.id == 'hello'"],
                        [Value, "v2", "v2.id == 'goodbye'"],
                        [Result, "r"]
                    ], function(facts, flow) {

...which causes a runtime error.

I'd expect the DSL rule to compile down to something more like:

                    }, ["or", [ 
                                  [Value, "v1", "v1.id == 'hello'"],
                                  [Value, "v2", "v2.id == 'goodbye'"]
                                ],
                        [Result, "r"]
                    ], function(facts, flow) {

...which works fine at runtime.

Is my expectation correct?

@ghost ghost assigned doug-martin Aug 22, 2013

doug-martin added a commit to doug-martin/nools that referenced this issue Aug 22, 2013

@doug-martin doug-martin referenced this issue Aug 22, 2013

Merged

v0.1.9 #54

doug-martin added a commit that referenced this issue Aug 22, 2013

v0.1.9
* Fixed issues where notNode was not retracting all contexts when a fact was retracted
* Fixed issue #50 in compiling rule with or condition
* Fixed issue #53 in constraints with hash refrences.
* Merged pull request #49
* Added tests for logicalNot and truthy statements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment