Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nools compile bug with key 'from' #168

Open
taoqf opened this issue Dec 22, 2015 · 1 comment
Open

nools compile bug with key 'from' #168

taoqf opened this issue Dec 22, 2015 · 1 comment
Labels

Comments

@taoqf
Copy link

taoqf commented Dec 22, 2015

i have been using nools for a while(v0.4.1) and i found a bug today.
when i compiled *.nools files using the command
nools compile -b test.nools > test.js
, i found the simple rule

function t(){
return 1;
}
rule 'r'{
when {
s: String;
n: Number from t();
}
then {
console.log('n is ', n);
}
}

i got the js file

this.rule("r", {
scope: scope
}, [ [ Number, "n", "true" ] ], function(facts, flow) {
var n = facts.n;
var console = scope.console;
var t = scope.t;
console.log("init");
});

"from test()" changed to "true"

i debugged and found the code in nools/lib/parser/nools/tokens.js:line158
rule.push(constraints);
should be changed into
constraints && rule.push(constraints);
i wish this could be resolved in feature because i cann't use compile in code which takes more time

@DevSide
Copy link
Collaborator

DevSide commented Oct 3, 2016

I would recommend to use from either with a constant, a fact or a set of facts. You're probably right about the evaluation problem of the from constraint.

@DevSide DevSide added the wontfix label Oct 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants