Bug 1471421 - gawk's PROCINFO["identifiers"] reports wrong type
gawk's PROCINFO["identifiers"] reports wrong type
Product: Fedora
Classification: Fedora
Component: gawk (Show other bugs)
All All
unspecified Severity medium
: ---
: ---
Assigned To: David Kaspar [Dee'Kej]
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2017-07-15 16:54 EDT by Peter Backes
Modified: 2017-07-17 10:55 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Peter Backes 2017-07-15 16:54:13 EDT
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 PROCINFO["identifiers"]["a"],PROCINFO["identifiers"]["seps"];}'

Actual results:
untyped untyped

Expected results:
array array

Additional info:
PROCINFO["identifiers"]["PROCINFO"] correctly reports "array".
Comment 1 Peter Backes 2017-07-15 17:06:22 EDT
Same behavior actually for numbers and strings:

% gawk 'BEGIN { x="test"; print PROCINFO["identifiers"]["x"];}'
% gawk 'BEGIN { x=5.5; print PROCINFO["identifiers"]["x"];}'
Comment 2 Peter Backes 2017-07-15 17:14:55 EDT
OK I guess it's 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)
Comment 3 Peter Backes 2017-07-16 06:02:59 EDT
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 have anyway, if it wouldn't handle this basic case well?
Comment 4 David Kaspar [Dee'Kej] 2017-07-17 06:49:41 EDT
Hello Peter,

thank you for reporting this. Unfortunately, I'm not part of gawk's upstream, nor I know much about it. You probably know much more than I do, actually... :)

Would you be, please, so kind and send your bug report to <bug-gawk@gnu.org>? In case upstream acknowledges this as a bug and fixes it, then I can create a new gawk release for you.

(I could report this to upstream on your behalf, but in case they reply I would become just a bottleneck in your communication. If you would write them the same thing you wrote me, it would speed things up much more. Upstream of gawk replies within few days usually. ;))

Thank you for your understanding.

Comment 5 Peter Backes 2017-07-17 07:38:09 EDT
Reported upstream
Comment 6 David Kaspar [Dee'Kej] 2017-07-17 10:55:21 EDT
(In reply to Peter Backes from comment #5)
> Reported upstream

Thank you very much! :)

Note You need to log in before you can comment on or make changes to this bug.