zls icon indicating copy to clipboard operation
zls copied to clipboard

zls gets confused when block labels and variables have the same name, renames the wrong one

Open xdBronch opened this issue 1 year ago • 0 comments

Zig Version

0.12.0-dev.2497+3c385340a

Zig Language Server Version

0.12.0-dev.365+a8a83b6

Client / Code Editor / Extensions

No response

Steps to Reproduce and Observed Behavior

test {
    const a = blk: {   // `a` cant be resolved
        const blk = 1; // `blk` is correctly resolved as comptime_int
                       // using zls to rename this variable leaves it intact and instead renames the label
                       // after the (incorrect) rename, `a` the variable is resolved
        break :blk blk;
    };
    try @import("std").testing.expectEqual(1, a);
}
test {
    const a = blk2: { // no ambiguity between the label and variable, `a` is resolved as comptime_int
        const blk = 1;
        break :blk2 blk;
    };
    try @import("std").testing.expectEqual(1, a);
}

Expected Behavior

zls should be able to resolve the value from the block, renaming should rename the right thing

Relevant log output

No response

xdBronch avatar Jan 26 '24 03:01 xdBronch