summaryrefslogtreecommitdiff
path: root/parse.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-04-19 17:13:26 -0400
committerLeo Tenenbaum <pommicket@gmail.com>2020-04-19 17:13:26 -0400
commitb79c4e942dba34ee1b2e5ce907629c7f77f88f07 (patch)
treeb89f880afde67f1dd6256a1df4bd772f67c1513a /parse.c
parent30caeaab671f7fe7d7582ce7e645302a139c15a0 (diff)
annotating index type for loops
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/parse.c b/parse.c
index 8901cb5..2befa8b 100644
--- a/parse.c
+++ b/parse.c
@@ -146,6 +146,9 @@ static bool type_builtin_is_numerical(BuiltinType b) {
return type_builtin_is_int(b) || type_builtin_is_float(b);
}
+static bool type_is_int(Type *t) {
+ return t->kind == TYPE_BUILTIN && type_builtin_is_int(t->builtin);
+}
/* returns -1 on failure */
static int kw_to_builtin_type(Keyword kw) {
@@ -1384,7 +1387,6 @@ static Status parse_expr(Parser *p, Expression *e, Token *end) {
e->kind = EXPR_FOR;
ForExpr *fo = e->for_ = parser_malloc(p, sizeof *fo);
fo->flags = 0;
- fo->type = NULL;
Block *prev_block = p->block;
fo->body.parent = p->block;
p->block = &fo->body;
@@ -2707,7 +2709,7 @@ static void fprint_expr(FILE *out, Expression *e) {
if (found_type) {
if (fo->range.stepval) {
fprintf(out, ",");
- fprint_val(out, *fo->range.stepval, fo->type);
+ fprint_val(out, *fo->range.stepval, &fo->header.type.tuple[0]);
}
} else {
if (fo->range.step) {