ir: Implement @TypeOf with multiple arguments

Closes #439
This commit is contained in:
LemonBoy
2020-03-04 10:55:34 +01:00
committed by Andrew Kelley
parent 24fc69acad
commit 0c310f0fbf
6 changed files with 93 additions and 14 deletions

View File

@@ -2,6 +2,24 @@ const tests = @import("tests.zig");
const std = @import("std");
pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.addTest("@TypeOf with no arguments",
\\export fn entry() void {
\\ _ = @TypeOf();
\\}
, &[_][]const u8{
"tmp.zig:2:9: error: expected at least 1 argument, found 0",
});
cases.addTest("@TypeOf with incompatible arguments",
\\export fn entry() void {
\\ var var_1: f32 = undefined;
\\ var var_2: u32 = undefined;
\\ _ = @TypeOf(var_1, var_2);
\\}
, &[_][]const u8{
"tmp.zig:4:9: error: incompatible types: 'f32' and 'u32'",
});
cases.addTest("type mismatch with tuple concatenation",
\\export fn entry() void {
\\ var x = .{};