forked from ziglang/zig
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes ziglang#10357 Closes ziglang#11236 Closes ziglang#11615 Closes ziglang#12055
- Loading branch information
Showing
5 changed files
with
56 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
test/cases/compile_errors/error_union_field_default_init.zig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const Input = struct { | ||
value: u32 = @as(error{}!u32, 0), | ||
}; | ||
export fn foo() void { | ||
var x: Input = Input{}; | ||
_ = &x; | ||
} | ||
|
||
// error | ||
// | ||
//:2:18: error: expected type 'u32', found 'error{}!u32' | ||
//:2:18: note: cannot convert error union to payload type | ||
//:2:18: note: consider using 'try', 'catch', or 'if' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
fn CreateType() !type { | ||
return struct {}; | ||
} | ||
const MyType = CreateType(); | ||
const TestType = struct { | ||
my_type: MyType, | ||
}; | ||
comptime { | ||
_ = @sizeOf(TestType) + 1; | ||
} | ||
|
||
// error | ||
// | ||
//:6:14: error: expected type 'type', found 'error{}!type' | ||
//:6:14: note: cannot convert error union to payload type | ||
//:6:14: note: consider using 'try', 'catch', or 'if' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
__attribute__ ((aligned(128))) | ||
extern char my_array[16]; | ||
__attribute__ ((aligned(128))) | ||
void my_fn(void) { } | ||
void other_fn(void) { | ||
char ARR[16] __attribute__ ((aligned (16))); | ||
} | ||
|
||
// translate-c | ||
// c_frontend=clang | ||
// | ||
//pub extern var my_array: [16]u8 align(128); | ||
//pub export fn my_fn() align(128) void {} | ||
//pub export fn other_fn() void { | ||
// var ARR: [16]u8 align(16) = undefined; | ||
// _ = &ARR; | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters