| author | |
| committer | |
| log | c1af3605328d21f59ee8ceba3c7350193f0a2429 |
| tree | a0a7ae69ff7a6772e8f341aad291278833d389ad |
| parent | 148fe2e99970ca880a8e10ded5af308e28bbc342 |
| signature | Commit is signed but in an unrecognized format. |
closes #13722 files changed, 16 insertions(+), 1 deletions(-)
src/ir.cpp+6-1| ... | ... | @@ -14874,8 +14874,13 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi |
| 14874 | 14874 | if (type_is_invalid(container_ptr->value.type)) |
| 14875 | 14875 | return ira->codegen->builtin_types.entry_invalid; |
| 14876 | 14876 | |
| 14877 | if (container_ptr->value.type->id != ZigTypeIdPointer) { | |
| 14878 | ir_add_error_node(ira, field_ptr_instruction->base.source_node, | |
| 14879 | buf_sprintf("attempt to dereference non-pointer type '%s'", | |
| 14880 | buf_ptr(&container_ptr->value.type->name))); | |
| 14881 | return ira->codegen->builtin_types.entry_invalid; | |
| 14882 | } | |
| 14877 | 14883 | ZigType *container_type = container_ptr->value.type->data.pointer.child_type; |
| 14878 | assert(container_ptr->value.type->id == ZigTypeIdPointer); | |
| 14879 | 14884 | |
| 14880 | 14885 | Buf *field_name = field_ptr_instruction->field_name_buffer; |
| 14881 | 14886 | if (!field_name) { |
test/compile_errors.zig+10| ... | ... | @@ -1,6 +1,16 @@ |
| 1 | 1 | const tests = @import("tests.zig"); |
| 2 | 2 | |
| 3 | 3 | pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 4 | cases.add( | |
| 5 | "deref slice and get len field", | |
| 6 | \\export fn entry() void { | |
| 7 | \\ var a: []u8 = undefined; | |
| 8 | \\ _ = a.*.len; | |
| 9 | \\} | |
| 10 | , | |
| 11 | ".tmp_source.zig:3:12: error: attempt to dereference non-pointer type '[]u8'", | |
| 12 | ); | |
| 13 | ||
| 4 | 14 | cases.add( |
| 5 | 15 | "@ptrCast a 0 bit type to a non- 0 bit type", |
| 6 | 16 | \\export fn entry() bool { |