reactorlabs / rir

GNU General Public License v2.0
62 stars 18 forks source link

Loops compile into a Function without DispatchTable #1294

Open rihafilip opened 1 month ago

rihafilip commented 1 month ago

When running

for (i in 1:10) {}

or

while(true) {}

in a global environment, a Function is compiled, but it is not in a DispatchTable (the dispatchTable_ field is uninitialized).

The eval function in eval.c calls do_for or do_while respectively. Then the call order is R_compileAndExecute -> R_compileExpr -> externalCodeCompile, which is a pointer to rirCompile -> rir::Compiler::compileExpression -> rir::Compiler::finalize, where the Function is created.

The created Function is afterwards called with rirEval thru R_compileAndExecute. The calling is going without any issue and this might not be a bug, but it is a weird behaviour.