Well, scratch the previous diff ... It also needs an extra test in the
if (for a Node_array_ref), so the correct diff should be:
diff --git a/builtin.c b/builtin.c
index 382922dbc..8fd0e1fc3 100644
--- a/builtin.c
+++ b/builtin.c
@@ -559,7 +559,11 @@ do_isarray(int nargs)
check_exact_args(nargs, "isarray", 1);
tmp = POP();
- if (tmp->type != Node_var_array) {
+
+ if (tmp->type == Node_param_list)
+ tmp = GET_PARAM(tmp->param_cnt);
+
+ if (tmp->type != Node_var_array && tmp->type != Node_array_ref)
{
ret = 0;
// could be Node_var_new
if (tmp->type == Node_val)
On 2025-01-06 13:18, mekanofox via "Bug reports only for gawk." wrote:
... and in that case ...
function f(y, ifc) { y[3]=14; ifc="isarray"; return @ifc(y) } BEGIN {
print f(z) }
0 # incorrect, because similarly do_isarray receives a Node_param_list
...
... should behave like:
function f(y) { y[3]=14; return isarray(y) } BEGIN { print f(z) }
1 # correct
... which means "do_isarray" needs the same treatment:
diff --git a/builtin.c b/builtin.c
index 382922dbc..17ee2c0ab 100644
--- a/builtin.c
+++ b/builtin.c
@@ -559,6 +559,10 @@ do_isarray(int nargs)
check_exact_args(nargs, "isarray", 1);
tmp = POP();
+
+ if (tmp->type == Node_param_list)
+ tmp = GET_PARAM(tmp->param_cnt);
+
if (tmp->type != Node_var_array) {
ret = 0;
// could be Node_var_new
On 2025-01-06 12:47, arnold@skeeve.com wrote:
Hello.
Thanks for the report. The fix is below.
Arnold
Denis Shirokov <cosmogen@gmail.com> wrote:
Hello
found an issue while experimenting with indirect function calls:
func _typeof( p ,f ) {
f = "awk::typeof"
return @f( p ) }
BEGIN{
f = "awk::typeof"
print "typeof: " @f( p )
print "_typeof: " _typeof( p )
}
outputs:
typeof: untyped'
gawk: ./bug.gwk:3: fatal: typeof: unknown argument type
`Node_param_list'
gawk:
GNU Awk 5.3.1, API 4.0, (GNU MPFR 4.0.2, GNU MP 6.1.2)
OS:
Windows 10 Pro (x64)
downloaded from: https://sourceforge.net/projects/ezwinports/files/
Best Regards
Denis Shirokov
-------------------------------------
diff --git a/builtin.c b/builtin.c
index f03ba701..e3beff7c 100644
--- a/builtin.c
+++ b/builtin.c
@@ -3113,6 +3113,10 @@ do_typeof(int nargs)
else
dbg = NULL;
arg = POP();
+
+ if (arg->type == Node_param_list)
+ arg = GET_PARAM(arg->param_cnt);
+
switch (arg->type) {
case Node_var_array:
/* Node_var_array is never UPREF'ed */