bug-gawk
[Top][All Lists]
Advanced

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

SYMTAB update inside function calls


From: M
Subject: SYMTAB update inside function calls
Date: Mon, 11 Dec 2023 19:34:32 +0100

Hi!
A quest for you all :)


From: userland
To: bug-gawk@gnu.org
Subject: SYMTAB update inside function calls

Configuration Information [Automatically generated, do not change]:
Machine: aarch64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2 -DNDEBUG
uname output: Linux localhost 4.19.113-perf-g01b4c0bc6315 #1 SMP PREEMPT
Tue Nov 1 23:34:34 CST 2022 aarch64 GNU/Linux
Machine Type: aarch64-unknown-linux-gnu


Gawk Version: 5.3.0

Attestation 1:
I have read https://www.gnu.org/software/gawk/manual/html_node/Bugs.html.
Yes

Attestation 2:
I have not modified the sources before building gawk.
True

Description:
I noticed the creation or modification of values using SYMTAB doesn't works
inside a function call, *only* if the variable to be update is a function
parameter.
        SYMTAB seems to be update only at funcion exiting.

Repeat-By:
[userland@localhost ~]$ cat s.awk

function foo(a, b, c) {
  d = -1
  printf("inside foo: c is %s, d is %s\n", typeof(c), typeof(d))
  SYMTAB["c"] = a + b
  SYMTAB["d"] = a * b
  printf("inside foo: c=%d, d=%d\n", c, d)
}

BEGIN {
  a = 2
  b = 3
  c = 1
  foo(a, b, c)
  printf("outside foo: c=%d (%s), d=%d (%s)\n", c, typeof(c), d, typeof(d))

}
[userland@localhost ~]$ AWK/gawk/gawk -f s.awk
inside foo: c is number, d is number
inside foo: c=1, d=6
outside foo: c=5 (number), d=6 (number)
[userland@localhost ~]$

Fix:
    Don't sure is a bug, albeit an unexpected behaviour. I've not found
mentions of this in the documentation, if I'm not wrong maybe a note should
be added there.







 me -> http://crap0101.altervista.org/


reply via email to

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