We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug Evaluator fails to walk a member with object expressions with an Identifier property
To Reproduce Steps to reproduce the behavior:
const { Evaluator } = require('@nlpjs/evaluator'); const evaluator = new Evaluator(); const script = ` obj[""+"x"].y; ({ a: 5, b: 7 })['a']; ({ a: 5, b: 7 })[n] `; const context = { obj: { x: { y: 555 } }, n: 'a' }; const answer = evaluator.evaluateAll(script, context); console.log(answer);
It shows in console [ 555, 5, undefined ]
[ 555, 5, undefined ]
Expected behavior It should show in console [555, 5, 5]
[555, 5, 5]
Additional context The walkMember should avoid the shortcut by property name and resolve the identifier by walk when the object type is ObjectExpression Here: https://github.com/axa-group/nlp.js/blob/master/packages/evaluator/src/evaluator.js#L182 And here: https://github.com/axa-group/nlp.js/blob/master/packages/evaluator/src/javascript-compiler.js#L239
if (node.property.type === 'Identifier') { return obj[node.property.name]; }
Should be:
if (node.property.type === 'Identifier' && node.object.type !== 'ObjectExpression') { return obj[node.property.name]; }
The text was updated successfully, but these errors were encountered:
Thanks @jesus-seijas-sp , improvement applied in e11249f. We'll publish a version before ending this year.
Sorry, something went wrong.
No branches or pull requests
Describe the bug
Evaluator fails to walk a member with object expressions with an Identifier property
To Reproduce
Steps to reproduce the behavior:
It shows in console
[ 555, 5, undefined ]
Expected behavior
It should show in console
[555, 5, 5]
Additional context
The walkMember should avoid the shortcut by property name and resolve the identifier by walk when the object type is ObjectExpression
Here:
https://github.com/axa-group/nlp.js/blob/master/packages/evaluator/src/evaluator.js#L182
And here:
https://github.com/axa-group/nlp.js/blob/master/packages/evaluator/src/javascript-compiler.js#L239
Should be:
The text was updated successfully, but these errors were encountered: