commit d2b7a4b57a9ae953a046f05eb2f1c54bf026c065
parent a0e81298366197c343aa773e4e95b0c0ef1a89b2
Author: Eyal Sawady <ecs@d2evs.net>
Date: Thu, 2 Sep 2021 02:44:46 +0000
append/insert: drop *unary-expression form
Signed-off-by: Eyal Sawady <ecs@d2evs.net>
Diffstat:
2 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/src/check.c b/src/check.c
@@ -349,13 +349,7 @@ check_expr_append(struct context *ctx,
"append must operate on a mutable slice");
return;
}
- if (expr->append.expr->type != EXPR_ACCESS
- && (expr->append.expr->type != EXPR_UNARITHM
- || expr->append.expr->unarithm.op != UN_DEREF)) {
- error(ctx, aexpr->append.expr->loc, expr,
- "append must operate on a slice object");
- return;
- }
+ assert(expr->append.expr->type == EXPR_ACCESS);
const struct type *memb = stype->array.members;
struct append_values **next = &expr->append.values;
for (struct ast_append_values *avalue = aexpr->append.values; avalue;
diff --git a/src/parse.c b/src/parse.c
@@ -389,6 +389,7 @@ parse_primitive_type(struct lexer *lexer)
static struct ast_expression *parse_binding_list(
struct lexer *lexer, bool is_static);
+static struct ast_expression *parse_object_selector(struct lexer *lexer);
static struct ast_type *
parse_enum_type(struct lexer *lexer)
@@ -1275,16 +1276,14 @@ parse_slice_mutation(struct lexer *lexer, bool is_static)
want(lexer, T_LPAREN, NULL);
struct ast_append_values **next;
- // Easier to parse an expression and let check limit it to
- // object-selector/*unary-expression
switch (exp->type) {
case EXPR_APPEND:
- exp->append.expr = parse_expression(lexer);
+ exp->append.expr = parse_object_selector(lexer);
exp->append.is_static = is_static;
next = &exp->append.values;
break;
case EXPR_INSERT:
- exp->insert.expr = parse_expression(lexer);
+ exp->insert.expr = parse_object_selector(lexer);
exp->insert.is_static = is_static;
next = &exp->insert.values;
break;