You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Declaring a function causes the function to be invoked. This is particularly nasty for array iteration methods, where the iterator will get invoked an extra time with a null value.
Here is a test that pinpoints the issue:
test('function declaration does not invoke function',function(t){t.plan(1);varinvoked=false;varvariables={noop: function(){},onInvoke: function(){invoked=true}};varsrc=`noop(function(){ onInvoke(); })`;varast=parse(src).body[0].expression;evaluate(ast,variables);t.equal(invoked,false);})
Here is a failing test that demonstrates the array use case:
The text was updated successfully, but these errors were encountered:
RoboPhred
changed the title
Function declaration invokes function body
Array iteration methods have extra invocation with a null value.
Feb 20, 2020
RoboPhred
changed the title
Array iteration methods have extra invocation with a null value.
Function declaration invokes the function body
Feb 20, 2020
The issue seems to be the walk on the function body here. We probably need a "checkOnly" flag to walk to suppress code invocation and allow it to simply check the validity of the body.
Declaring a function causes the function to be invoked. This is particularly nasty for array iteration methods, where the iterator will get invoked an extra time with a null value.
Here is a test that pinpoints the issue:
Here is a failing test that demonstrates the array use case:
The result of the deepEqual check is:
The text was updated successfully, but these errors were encountered: