Closed benhoyt closed 1 year ago
Thanks for the report! This isn't really about arrays, it's more about a hole in how frawk handles printing functions that type inference has inferred nothing about ("Null" values). The bug goes away if you do BEGIN { f(0); }
for example.
The issue here is that frawk monomorphizes functions: in this case it creates two copies of f
based on the initial call-site and the recursive call.
frawk isn't able to infer any type information about depth
in the first call, other than the fact that it is a scalar (indeed, you could pass it the empty string and it would produce the same output), but the recursive call always gets called with an int (depth+1), so we only get an error with depth 0.
The easiest fix I found was just to support "null" as a valid format argument type. Added your repro as a test case. Thanks again!
With the following program, I'm seeing the message "failure in runtime invalid format arg Null (this should have been caught earlier). Halting execution" from frawk:
And the output:
However, under Gawk/mawk/onetrueawk/goawk, this program works fine, and prints the extra line of output:
Something to do with local arrays?