diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-02-26 15:34:02 +0000 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-02-26 15:34:02 +0000 |
| commit | 9bc37f44002d89ed35643b2bfd8c384cb5ff1f48 (patch) | |
| tree | b17097dec012a4006958e8fdb740dfc9b0c097fc /src | |
| parent | f29e303ce7b11fbe88a4b63374c08130c6c189dd (diff) | |
fmt.odin uses ^[]byte rather than custom Buffer type
Diffstat (limited to 'src')
| -rw-r--r-- | src/check_expr.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/check_expr.c b/src/check_expr.c index 264a5d072..0e166ef1a 100644 --- a/src/check_expr.c +++ b/src/check_expr.c @@ -5127,6 +5127,10 @@ ExprKind check__expr_base(Checker *c, Operand *o, AstNode *node, Type *type_hint switch (t->kind) { case Type_Basic: if (is_type_string(t)) { + if (se->index3) { + error_node(node, "3-index slice on a string in not needed"); + goto error; + } valid = true; if (o->mode == Addressing_Constant) { max_count = o->value.value_string.len; @@ -5167,14 +5171,20 @@ ExprKind check__expr_base(Checker *c, Operand *o, AstNode *node, Type *type_hint o->mode = Addressing_Value; } + if (se->index3 && (se->high == NULL || se->max == NULL)) { + error(se->close, "2nd and 3rd indices are required in a 3-index slice"); + goto error; + } + i64 indices[2] = {0}; - AstNode *nodes[2] = {se->low, se->high}; + AstNode *nodes[3] = {se->low, se->high, se->max}; for (isize i = 0; i < gb_count_of(nodes); i++) { i64 index = max_count; if (nodes[i] != NULL) { i64 capacity = -1; - if (max_count >= 0) + if (max_count >= 0) { capacity = max_count; + } i64 j = 0; if (check_index_value(c, nodes[i], capacity, &j)) { index = j; |