Skip to content

Field rename does not rename struct initialization's fields #1837

@johan0A

Description

@johan0A

Zig Version

0.12.0-dev.3245+4f782d1e8

Zig Language Server Version

0.12.0-dev.496+96eddd0

Client / Code Editor / Extensions

vscode

Steps to Reproduce and Observed Behavior

Rename field inside TestStruct, initialize struct using syntax below ⇾ the initialization does not get updated

const TestStruct = struct {
    test_var_renamed: i32, //field was renamed here
};

test "test" {
    const test_struct: TestStruct = .{
        .test_var = 1, //does not get renamed
    };

    const test_struct2: TestStruct = TestStruct{
        .test_var = 1, //does not get renamed
    };

    std.debug.print("{}", .{test_struct});
    std.debug.print("{}", .{test_struct2});
}

Expected Behavior

const TestStruct = struct {
    test_var_renamed: i32, //field was renamed here
};

test "test" {
    const test_struct: TestStruct = .{
        .test_var_renamed = 1, //gets renamed
    };

    const test_struct2: TestStruct = TestStruct{
        .test_var_renamed = 1, //gets renamed
    };

    std.debug.print("{}", .{test_struct});
    std.debug.print("{}", .{test_struct2});
}

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions