[Top][All Lists]

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

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

From: Peter Backes
Subject: [bug-gawk] gawk's PROCINFO["identifiers"] fails to report type
Date: Mon, 17 Jul 2017 13:37:24 +0200
User-agent: Mutt/1.8.0 (2017-02-23)


This was originally reported at 

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):

How reproducible:

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

Actual results:
untyped untyped

Expected results:
array array

Additional info:
Same behavior actually for numbers and strings:

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

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

Peter Backes, address@hidden

reply via email to

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