bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] gawk's PROCINFO["identifiers"] fails to report type


From: Manuel Collado
Subject: Re: [bug-gawk] gawk's PROCINFO["identifiers"] fails to report type
Date: Mon, 17 Jul 2017 16:55:23 +0200
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0

What you want, i.e. to have the current type information at run-time, will be available in the next gawk release as a builtin typeof(variable) function. Please build from the master GIT sources to test it.

The current gawk-4.1.4 only has an isarray(variable) built-in function that discriminates between arrays and scalars.

HTH.

El 17/07/2017 a las 13:37, Peter Backes escribió:
Hello,

This was originally reported at
https://bugzilla.redhat.com/show_bug.cgi?id=1471421

Description of problem:
when asking AWK for the type of an array variable, it incorrectly
claims that it is untyped.

Version-Release number of selected component (if applicable):
gawk-4.1.3-8.fc25.i686

How reproducible:
always

Steps to Reproduce:
1. gawk 'BEGIN { testx["bla"]="foo";testx["bla2"]="foo2";print
PROCINFO["identifiers"]["testx"]; split("cul-de-sac",a,"-",seps); print
PROCINFO["identifiers"]["a"],PROCINFO["identifiers"]["seps"];}'

Actual results:
untyped
untyped untyped

Expected results:
array
array array

Additional info:
Same behavior actually for numbers and strings:

% gawk 'BEGIN { x="test"; print PROCINFO["identifiers"]["x"];}'
untyped
% gawk 'BEGIN { x=5.5; print PROCINFO["identifiers"]["x"];}'
untyped

Perhaps it is because "The values indicate what gawk knows about the
identifiers after it has finished parsing the program; they are not
updated while the program runs"
(https://www.gnu.org/software/gawk/manual/gawk.html)? Although I still
think it's a bug. In the examples given, the type IS statically known
after parsing. Because the respective identifiers are used in only one,
unique type of context. 'testx["bla"]="foo"' clearly says that testx is
an array, and if there is no conflicting assignment (such as testx =
"xyz") afterwards or before, the type must be array. What purpose would
PROCINFO["identifiers"] have anyway, if it wouldn't handle this basic
case well?

PROCINFO["identifiers"]["PROCINFO"] correctly reports "array".

Best wishes
Peter Backes


--
Manuel Collado - http://lml.ls.fi.upm.es/~mcollado




reply via email to

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