| author | |
| committer | |
| log | 44f38b04b0cc374fcd377df0fe68f29c824185ff |
| tree | 4d3302eeb87b768a8d1d0b78eaebc54daf077f2e |
| parent | 40ca39d3d5a556e3b5d7298e3a5182f4351bdd17 |
closes #6972 files changed, 11 insertions(+), 0 deletions(-)
src/analyze.cpp+4| ... | ... | @@ -3295,6 +3295,10 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var) { |
| 3295 | 3295 | is_const, init_val, &tld_var->base); |
| 3296 | 3296 | tld_var->var->linkage = linkage; |
| 3297 | 3297 | |
| 3298 | if (implicit_type != nullptr && type_is_invalid(implicit_type)) { | |
| 3299 | tld_var->var->value->type = g->builtin_types.entry_invalid; | |
| 3300 | } | |
| 3301 | ||
| 3298 | 3302 | if (var_decl->align_expr != nullptr) { |
| 3299 | 3303 | if (!analyze_const_align(g, tld_var->base.parent_scope, var_decl->align_expr, &tld_var->var->align_bytes)) { |
| 3300 | 3304 | tld_var->var->value->type = g->builtin_types.entry_invalid; |
test/compile_errors.zig+7| ... | ... | @@ -1,6 +1,13 @@ |
| 1 | 1 | const tests = @import("tests.zig"); |
| 2 | 2 | |
| 3 | 3 | pub fn addCases(cases: &tests.CompileErrorContext) void { |
| 4 | cases.add("use invalid number literal as array index", | |
| 5 | \\var v = 25; | |
| 6 | \\export fn entry() void { | |
| 7 | \\ var arr: [v]u8 = undefined; | |
| 8 | \\} | |
| 9 | , ".tmp_source.zig:1:1: error: unable to infer variable type"); | |
| 10 | ||
| 4 | 11 | cases.add("duplicate struct field", |
| 5 | 12 | \\const Foo = struct { |
| 6 | 13 | \\ Bar: i32, |