diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/builtins.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/builtins.c b/src/builtins.c index 64de6b5..8d985fe 100644 --- a/src/builtins.c +++ b/src/builtins.c @@ -1012,6 +1012,7 @@ void qstack(value_t *v) { } void vat(value_t *v) { + value_t *retval; value_t *v2 = array_pop(STACK); if (v2 == NULL) { eval_error("EMTPY STACK"); @@ -1040,7 +1041,7 @@ void vat(value_t *v) { array_append(STACK, v2); array_append(STACK, value_copy(v2->quote->items[(int)v1->int_float])); value_free(v1); - } else if (v2->type == VSTR) { + } else if (v2->type == VSTR || v2->type == VWORD) { if (v2->str_word->length <= v1->int_float) { array_append(STACK, v1); array_append(STACK, v2); @@ -1049,7 +1050,11 @@ void vat(value_t *v) { } char *a = (char[]){v2->str_word->value[(int)v1->int_float], '\0'}; string_t *s = init_string(a); - value_t *retval = init_value(VSTR); + if (v2->type == VWORD) { + retval = init_value(VWORD); + } else { + retval = init_value(VSTR); + } retval->str_word = s; array_append(STACK, v2); array_append(STACK, retval); |