aboutsummaryrefslogtreecommitdiffstats
path: root/test/aryunasgn.awk
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2017-08-09 21:01:19 +0300
committerArnold D. Robbins <arnold@skeeve.com>2017-08-09 21:01:19 +0300
commitc51a97fc72b732d19dbc83a7a4aadf9893a92b78 (patch)
tree6a6baa3581785d9f911476264fa0826d18244103 /test/aryunasgn.awk
parent66a471664f2bf33b35a10db017a1f7ff194d5163 (diff)
downloadegawk-c51a97fc72b732d19dbc83a7a4aadf9893a92b78.tar.gz
egawk-c51a97fc72b732d19dbc83a7a4aadf9893a92b78.tar.bz2
egawk-c51a97fc72b732d19dbc83a7a4aadf9893a92b78.zip
Fix array indexing from unassigned var to not keep that attribute.
Diffstat (limited to 'test/aryunasgn.awk')
-rw-r--r--test/aryunasgn.awk17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/aryunasgn.awk b/test/aryunasgn.awk
new file mode 100644
index 00000000..ccb3fd23
--- /dev/null
+++ b/test/aryunasgn.awk
@@ -0,0 +1,17 @@
+BEGIN {
+ a[i] = "null" # i is initially undefined
+ for (i in a) { # i is null string
+ print length(i), a[i] # , typeof(i) # 0 null
+ print (i==0), (i=="") # 1 1 should be 0 1
+ }
+ print a[""] # null
+ print a[0] #
+
+ b[$2] = "null also" # $2 is also undefined
+ for (j in b) {
+ print length(j), a[j] # , typeof(i) # 0 null
+ print (j==0), (j=="") # 1 1 should be 0 1
+ }
+ print b[""] # null
+ print b[0] #
+}