From b85bb152bf4c84a298200703d9a005ffcd1b24a0 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 8 Mar 2020 19:18:06 +1100 Subject: [PATCH 1/2] Fix grammar in error message --- src/ir.cpp | 2 +- test/compile_errors.zig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ir.cpp b/src/ir.cpp index 86d85303c0..86a5cf0617 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -30246,7 +30246,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { return ErrorSemanticAnalyzeFail; } else if (elem_type->id == ZigTypeIdOpaque) { ir_add_error(ira, &lazy_ptr_type->elem_type->base, - buf_sprintf("C pointers cannot point opaque types")); + buf_sprintf("C pointers cannot point to opaque types")); return ErrorSemanticAnalyzeFail; } else if (lazy_ptr_type->is_allowzero) { ir_add_error(ira, &lazy_ptr_type->elem_type->base, diff --git a/test/compile_errors.zig b/test/compile_errors.zig index f559311547..e402197a8e 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -1592,7 +1592,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { \\ var y: [*c]c_void = x; \\} , &[_][]const u8{ - "tmp.zig:3:16: error: C pointers cannot point opaque types", + "tmp.zig:3:16: error: C pointers cannot point to opaque types", }); cases.add("directly embedding opaque type in struct and union", From c8050a931c11e34bc6f4723eaed30f0a1bde5b14 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 8 Mar 2020 19:18:25 +1100 Subject: [PATCH 2/2] Strip trailing whitespace from src/ir.cpp --- src/ir.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ir.cpp b/src/ir.cpp index 86a5cf0617..34f3ef26a7 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -9014,7 +9014,7 @@ static IrInstSrc *ir_gen_switch_expr(IrBuilderSrc *irb, Scope *scope, AstNode *n return irb->codegen->invalid_inst_src; } else_prong = prong_node; - } else if (prong_item_count == 1 && + } else if (prong_item_count == 1 && prong_node->data.switch_prong.items.at(0)->type == NodeTypeSymbol && buf_eql_str(prong_node->data.switch_prong.items.at(0)->data.symbol_expr.symbol, "_")) { if (underscore_prong) { @@ -26068,7 +26068,7 @@ static IrInstGen *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstSrcSlice *i if (array_type->data.pointer.ptr_len == PtrLenC) { array_type = adjust_ptr_len(ira->codegen, array_type, PtrLenUnknown); - // C pointers are allowzero by default. + // C pointers are allowzero by default. // However, we want to be able to slice them without generating an allowzero slice (see issue #4401). // To achieve this, we generate a runtime safety check and make the slice type non-allowzero. if (array_type->data.pointer.allow_zero) { @@ -26363,7 +26363,7 @@ static IrInstGen *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstSrcSlice *i if (type_is_invalid(ptr_val->value->type)) return ira->codegen->invalid_inst_gen; - + ir_build_assert_non_null(ira, &instruction->base.base, ptr_val); }