diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-09-23 15:58:04 +0300 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-09-23 17:39:06 +0300 |
| commit | 581df942e1150dc2108bef1d91f0a77ba9c32e23 (patch) | |
| tree | 72403a12232cffbb1635a43109c587b663e14b7e /test/cases/compile_errors | |
| parent | 3de5c3b5038d03759d8f5521627fdbbcad28c795 (diff) | |
| download | zig-581df942e1150dc2108bef1d91f0a77ba9c32e23.tar.gz zig-581df942e1150dc2108bef1d91f0a77ba9c32e23.zip | |
Sema: correct sentinel check on implicit cast from array ptr
Closes #12938
Diffstat (limited to 'test/cases/compile_errors')
| -rw-r--r-- | test/cases/compile_errors/implicit_array_ptr_cast_sentinel_mismatch.zig | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/cases/compile_errors/implicit_array_ptr_cast_sentinel_mismatch.zig b/test/cases/compile_errors/implicit_array_ptr_cast_sentinel_mismatch.zig new file mode 100644 index 0000000000..ff7a2737dc --- /dev/null +++ b/test/cases/compile_errors/implicit_array_ptr_cast_sentinel_mismatch.zig @@ -0,0 +1,23 @@ +fn foo() [:0xff]const u8 { + return "bark"; +} +fn bar() [:0]const u16 { + return "bark"; +} +pub export fn entry() void { + _ = foo(); +} +pub export fn entry1() void { + _ = bar(); +} + +// error +// backend=stage2 +// target=native +// +// :2:12: error: expected type '[:255]const u8', found '*const [4:0]u8' +// :2:12: note: pointer sentinel '0' cannot cast into pointer sentinel '255' +// :1:10: note: function return type declared here +// :5:12: error: expected type '[:0]const u16', found '*const [4:0]u8' +// :5:12: note: pointer type child 'u8' cannot cast into pointer type child 'u16' +// :4:10: note: function return type declared here |
