authorgravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2020-04-03 21:04:22-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2020-04-03 21:04:22-04:00
log1568470c44eafb59425c070ea9884b78cc2516b2
tree114d9538a30d29fe39cf133cabbe810a9f758d89
parentdb4c06ce606dcfe989b5c1f76d5ed00e90d5dd9f
parent8b6a06eefe8738896a6657c86af5770250e0b67a
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #4891 from mikdusan/issue4207

add compiler-error test: coerce

1 files changed, 10 insertions(+), 0 deletions(-)

test/compile_errors.zig+10
...@@ -7152,4 +7152,14 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -7152,4 +7152,14 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
7152 ":39:29: error: slice-sentinel does not match target-sentinel",7152 ":39:29: error: slice-sentinel does not match target-sentinel",
7153 ":46:29: error: slice-sentinel does not match target-sentinel",7153 ":46:29: error: slice-sentinel does not match target-sentinel",
7154 });7154 });
7155
7156 cases.add("issue #4207: coerce from non-terminated-slice to terminated-pointer",
7157 \\export fn foo() [*:0]const u8 {
7158 \\ var buffer: [64]u8 = undefined;
7159 \\ return buffer[0..];
7160 \\}
7161 , &[_][]const u8{
7162 ":3:18: error: expected type '[*:0]const u8', found '*[64]u8'",
7163 ":3:18: note: destination pointer requires a terminating '0' sentinel",
7164 });
7155}7165}