aboutsummaryrefslogtreecommitdiffstats
path: root/builtin.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2021-11-22 21:58:27 +0200
committerArnold D. Robbins <arnold@skeeve.com>2021-11-22 21:58:27 +0200
commit8720ea146e6951e4fe074087f0251a681b77ea50 (patch)
tree75c59197fe3cb84d73fa038632ec38de0e749c0f /builtin.c
parentf75d149be03ada58d261e4e2c501e648e55fd66c (diff)
parentf44bcf14b40716abe45306b0ca427a2b8359f28f (diff)
downloadegawk-8720ea146e6951e4fe074087f0251a681b77ea50.tar.gz
egawk-8720ea146e6951e4fe074087f0251a681b77ea50.tar.bz2
egawk-8720ea146e6951e4fe074087f0251a681b77ea50.zip
Merge branch 'master' into feature/docit
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/builtin.c b/builtin.c
index c27b5081..386b6ed4 100644
--- a/builtin.c
+++ b/builtin.c
@@ -4189,10 +4189,31 @@ do_typeof(int nargs)
}
break;
case Node_var_new:
- case Node_array_ref:
res = "untyped";
deref = false;
break;
+ case Node_array_ref:
+ /*
+ * function f(x) {
+ * print typeof(x)
+ * y = x
+ * print typeof(x)
+ * }
+ *
+ * BEGIN {
+ * print typeof(x)
+ * f(x)
+ * }
+ */
+ if (arg->orig_array->type == Node_var
+ && (arg->orig_array->var_value == Nnull_string
+ || (arg->orig_array->var_value->flags & NULL_FIELD) != 0)) {
+ res = "unassigned";
+ } else {
+ res = "untyped";
+ }
+ deref = false;
+ break;
case Node_var:
/*
* Note: this doesn't happen because the function calling code