mirror of
https://github.com/ziglang/zig.git
synced 2025-01-23 18:31:44 +00:00
parent
40ca39d3d5
commit
44f38b04b0
@ -3295,6 +3295,10 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var) {
|
||||
is_const, init_val, &tld_var->base);
|
||||
tld_var->var->linkage = linkage;
|
||||
|
||||
if (implicit_type != nullptr && type_is_invalid(implicit_type)) {
|
||||
tld_var->var->value->type = g->builtin_types.entry_invalid;
|
||||
}
|
||||
|
||||
if (var_decl->align_expr != nullptr) {
|
||||
if (!analyze_const_align(g, tld_var->base.parent_scope, var_decl->align_expr, &tld_var->var->align_bytes)) {
|
||||
tld_var->var->value->type = g->builtin_types.entry_invalid;
|
||||
|
@ -1,6 +1,13 @@
|
||||
const tests = @import("tests.zig");
|
||||
|
||||
pub fn addCases(cases: &tests.CompileErrorContext) void {
|
||||
cases.add("use invalid number literal as array index",
|
||||
\\var v = 25;
|
||||
\\export fn entry() void {
|
||||
\\ var arr: [v]u8 = undefined;
|
||||
\\}
|
||||
, ".tmp_source.zig:1:1: error: unable to infer variable type");
|
||||
|
||||
cases.add("duplicate struct field",
|
||||
\\const Foo = struct {
|
||||
\\ Bar: i32,
|
||||
|
Loading…
Reference in New Issue
Block a user