bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fatal: typeof: unknown argument type `Node_param_list'


From: mekanofox
Subject: Re: fatal: typeof: unknown argument type `Node_param_list'
Date: Mon, 06 Jan 2025 14:57:21 +0000
User-agent: Purely Mail via Roundcube/1.6.8

Double-scratch: the previous is not correct yet ... The test inside needs to be even more involved, something like this:

diff --git a/builtin.c b/builtin.c
index 382922dbc..7575110c2 100644
--- a/builtin.c
+++ b/builtin.c
@@ -559,11 +559,17 @@ 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
-               if (tmp->type == Node_val)
-                       DEREF(tmp);
+ if (tmp->type != Node_array_ref || tmp->orig_array->type != Node_var_array) {
+                       ret = 0;
+                       // could be Node_var_new
+                       if (tmp->type == Node_val)
+                               DEREF(tmp);
+               }
        }
        return make_number((AWKNUM) ret);
 }

I guess all these cases and variations should be added in the test suite ... For the past couple of posts I had to double check that previous variations still pass or fail instead of just firing up a 'make check'. (especially the previous diff, which was quite wrong, but yet the test suite did not catch anything).


On 2025-01-06 13:30, mekanofox via "Bug reports only for gawk." wrote:

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 */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]