bug-gawk
[Top][All Lists]
Advanced

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

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

-- 
Peter Backes, address@hidden



reply via email to

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