diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2025-11-06 09:37:16 +0000 |
|---|---|---|
| committer | gingerBill <gingerBill@users.noreply.github.com> | 2025-11-06 09:37:16 +0000 |
| commit | 4ce01854d57aa31c2b08a917b78ccff6f6d5c52e (patch) | |
| tree | c091d5cb60283bc726ee4b937ba05319e4f8da4a /src | |
| parent | 5bf3e0e87c28efdd2e1a2089304237b02675a647 (diff) | |
Improve error positioning for `#all_or_none`
Diffstat (limited to 'src')
| -rw-r--r-- | src/check_expr.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 677735c44..418fb5378 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -9857,6 +9857,12 @@ gb_internal void check_compound_literal_field_values(CheckerContext *c, Slice<As } if (missing_fields.count > 0) { + Ast *expr = o->expr; + if (expr == nullptr) { + GB_ASSERT(elems.count > 0); + expr = elems[elems.count-1]; + } + ERROR_BLOCK(); if (build_context.terse_errors) { @@ -9872,9 +9878,9 @@ gb_internal void check_compound_literal_field_values(CheckerContext *c, Slice<As i += 1; } - error(o->expr, "All or none of the fields must be assigned to a struct with '#all_or_none' applied, missing fields: %s", fields_string); + error(expr, "All or none of the fields must be assigned to a struct with '#all_or_none' applied, missing fields: %s", fields_string); } else { - error(o->expr, "All or none of the fields must be assigned to a struct with '#all_or_none' applied, missing fields:"); + error(expr, "All or none of the fields must be assigned to a struct with '#all_or_none' applied, missing fields:"); FOR_PTR_SET(field, missing_fields) { gbString s = type_to_string(field->type); error_line("\t%.*s: %s\n", LIT(field->token.string), s); |