| author | |
| committer | |
| log | b66547e98c9034e52c5647735b47dc24939c8d15 |
| tree | b84792ffb976bdad957943043b86c515d8905ad4 |
| parent | 884b5fb4cfa81fba863f24cf5c6d9d7c2a21d11f |
| parent | 0845cbe27783486feb5b4b57b2839326a2c86a6b |
| signature |
name types inside functions after variable3 files changed, 27 insertions(+), 6 deletions(-)
src/ir.cpp+6| ... | @@ -4172,7 +4172,13 @@ static IrInstruction *ir_gen_var_decl(IrBuilder *irb, Scope *scope, AstNode *nod | ... | @@ -4172,7 +4172,13 @@ static IrInstruction *ir_gen_var_decl(IrBuilder *irb, Scope *scope, AstNode *nod |
| 4172 | buf_sprintf("cannot set section of local variable '%s'", buf_ptr(variable_declaration->symbol))); | 4172 | buf_sprintf("cannot set section of local variable '%s'", buf_ptr(variable_declaration->symbol))); |
| 4173 | } | 4173 | } |
| 4174 | 4174 | ||
| 4175 | // Temporarily set the name of the IrExecutable to the VariableDeclaration | ||
| 4176 | // so that the struct or enum from the init expression inherits the name. | ||
| 4177 | Buf *old_exec_name = irb->exec->name; | ||
| 4178 | irb->exec->name = variable_declaration->symbol; | ||
| 4175 | IrInstruction *init_value = ir_gen_node(irb, variable_declaration->expr, scope); | 4179 | IrInstruction *init_value = ir_gen_node(irb, variable_declaration->expr, scope); |
| 4180 | irb->exec->name = old_exec_name; | ||
| 4181 | |||
| 4176 | if (init_value == irb->codegen->invalid_instruction) | 4182 | if (init_value == irb->codegen->invalid_instruction) |
| 4177 | return init_value; | 4183 | return init_value; |
| 4178 | 4184 |
std/fmt/index.zig+4-6| ... | @@ -550,12 +550,6 @@ test "parse unsigned comptime" { | ... | @@ -550,12 +550,6 @@ test "parse unsigned comptime" { |
| 550 | } | 550 | } |
| 551 | } | 551 | } |
| 552 | 552 | ||
| 553 | // Dummy field because of https://github.com/zig-lang/zig/issues/557. | ||
| 554 | // At top level because of https://github.com/zig-lang/zig/issues/675. | ||
| 555 | const Struct = struct { | ||
| 556 | unused: u8, | ||
| 557 | }; | ||
| 558 | |||
| 559 | test "fmt.format" { | 553 | test "fmt.format" { |
| 560 | { | 554 | { |
| 561 | var buf1: [32]u8 = undefined; | 555 | var buf1: [32]u8 = undefined; |
| ... | @@ -588,6 +582,10 @@ test "fmt.format" { | ... | @@ -588,6 +582,10 @@ test "fmt.format" { |
| 588 | assert(mem.eql(u8, result, "u3: 5\n")); | 582 | assert(mem.eql(u8, result, "u3: 5\n")); |
| 589 | } | 583 | } |
| 590 | { | 584 | { |
| 585 | // Dummy field because of https://github.com/zig-lang/zig/issues/557. | ||
| 586 | const Struct = struct { | ||
| 587 | unused: u8, | ||
| 588 | }; | ||
| 591 | var buf1: [32]u8 = undefined; | 589 | var buf1: [32]u8 = undefined; |
| 592 | const value = Struct { | 590 | const value = Struct { |
| 593 | .unused = 42, | 591 | .unused = 42, |
test/cases/misc.zig+17| ... | @@ -499,12 +499,29 @@ test "@canImplicitCast" { | ... | @@ -499,12 +499,29 @@ test "@canImplicitCast" { |
| 499 | } | 499 | } |
| 500 | 500 | ||
| 501 | test "@typeName" { | 501 | test "@typeName" { |
| 502 | const Struct = struct { | ||
| 503 | }; | ||
| 504 | const Union = union { | ||
| 505 | unused: u8, | ||
| 506 | }; | ||
| 507 | const Enum = enum { | ||
| 508 | Unused, | ||
| 509 | }; | ||
| 502 | comptime { | 510 | comptime { |
| 503 | assert(mem.eql(u8, @typeName(i64), "i64")); | 511 | assert(mem.eql(u8, @typeName(i64), "i64")); |
| 504 | assert(mem.eql(u8, @typeName(&usize), "&usize")); | 512 | assert(mem.eql(u8, @typeName(&usize), "&usize")); |
| 513 | // https://github.com/zig-lang/zig/issues/675 | ||
| 514 | assert(mem.eql(u8, @typeName(TypeFromFn(u8)), "TypeFromFn(u8)")); | ||
| 515 | assert(mem.eql(u8, @typeName(Struct), "Struct")); | ||
| 516 | assert(mem.eql(u8, @typeName(Union), "Union")); | ||
| 517 | assert(mem.eql(u8, @typeName(Enum), "Enum")); | ||
| 505 | } | 518 | } |
| 506 | } | 519 | } |
| 507 | 520 | ||
| 521 | fn TypeFromFn(comptime T: type) type { | ||
| 522 | return struct {}; | ||
| 523 | } | ||
| 524 | |||
| 508 | test "volatile load and store" { | 525 | test "volatile load and store" { |
| 509 | var number: i32 = 1234; | 526 | var number: i32 = 1234; |
| 510 | const ptr = (&volatile i32)(&number); | 527 | const ptr = (&volatile i32)(&number); |