aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-11-24 20:25:14 -0500
committerAndrew Kelley <andrew@ziglang.org>2019-11-24 20:25:14 -0500
commitb9f88c3552c0ac892aa6dba7ed8518a0aee51305 (patch)
tree708d70c749f2501ad8b3b57f0870c5ad4ee6a0bc /src/ir.cpp
parentce96323ba15309c08b868c442ef4511c244e2e83 (diff)
downloadzig-b9f88c3552c0ac892aa6dba7ed8518a0aee51305.tar.gz
zig-b9f88c3552c0ac892aa6dba7ed8518a0aee51305.zip
fix compile errors for array sentinels mismatching
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index a61f0deff1..e0f53094d0 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -12661,21 +12661,27 @@ static void report_recursive_error(IrAnalyze *ira, AstNode *source_node, ConstCa
{
Buf *txt_msg = buf_sprintf("destination pointer requires a terminating '");
render_const_value(ira->codegen, txt_msg, wanted_type->data.pointer.sentinel);
- buf_appendf(txt_msg, "' sentinel value");
+ buf_appendf(txt_msg, "' sentinel");
if (actual_type->data.pointer.sentinel != nullptr) {
buf_appendf(txt_msg, ", but source pointer has a terminating '");
render_const_value(ira->codegen, txt_msg, actual_type->data.pointer.sentinel);
- buf_appendf(txt_msg, "' sentinel value");
+ buf_appendf(txt_msg, "' sentinel");
}
add_error_note(ira->codegen, parent_msg, source_node, txt_msg);
}
break;
}
case ConstCastResultIdSentinelArrays: {
+ ZigType *actual_type = cast_result->data.sentinel_arrays->actual_type;
ZigType *wanted_type = cast_result->data.sentinel_arrays->wanted_type;
Buf *txt_msg = buf_sprintf("destination array requires a terminating '");
- render_const_value(ira->codegen, txt_msg, wanted_type->data.pointer.sentinel);
- buf_appendf(txt_msg, "' sentinel value");
+ render_const_value(ira->codegen, txt_msg, wanted_type->data.array.sentinel);
+ buf_appendf(txt_msg, "' sentinel");
+ if (actual_type->data.array.sentinel != nullptr) {
+ buf_appendf(txt_msg, ", but source array has a terminating '");
+ render_const_value(ira->codegen, txt_msg, actual_type->data.array.sentinel);
+ buf_appendf(txt_msg, "' sentinel");
+ }
add_error_note(ira->codegen, parent_msg, source_node, txt_msg);
break;
}