stage2: compile error for invalid var type

This commit is contained in:
Andrew Kelley
2020-12-31 17:24:36 -07:00
parent 79a9391414
commit 982acc22fd
6 changed files with 117 additions and 50 deletions

View File

@@ -3421,3 +3421,9 @@ pub fn getTarget(self: Module) Target {
pub fn optimizeMode(self: Module) std.builtin.Mode {
return self.comp.bin_file.options.optimize_mode;
}
pub fn validateVarType(mod: *Module, scope: *Scope, src: usize, ty: Type) !void {
if (!ty.isValidVarType(false)) {
return mod.fail(scope, src, "variable of type '{}' must be const or comptime", .{ty});
}
}