mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 22:35:24 +00:00
AstGen: fix incorrect handling of source cursor with shift builtins
Closes #13714
This commit is contained in:
parent
7be6f352e3
commit
f4afeb3ffd
@ -8551,11 +8551,18 @@ fn shiftOp(
|
||||
rhs_node: Ast.Node.Index,
|
||||
tag: Zir.Inst.Tag,
|
||||
) InnerError!Zir.Inst.Ref {
|
||||
var line = gz.astgen.source_line - gz.decl_line;
|
||||
var column = gz.astgen.source_column;
|
||||
const lhs = try expr(gz, scope, .{ .rl = .none }, lhs_node);
|
||||
|
||||
maybeAdvanceSourceCursorToMainToken(gz, node);
|
||||
const line = gz.astgen.source_line - gz.decl_line;
|
||||
const column = gz.astgen.source_column;
|
||||
switch (gz.astgen.tree.nodes.items(.tag)[node]) {
|
||||
.shl, .shr => {
|
||||
maybeAdvanceSourceCursorToMainToken(gz, node);
|
||||
line = gz.astgen.source_line - gz.decl_line;
|
||||
column = gz.astgen.source_column;
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
|
||||
const log2_int_type = try gz.addUnNode(.typeof_log2_int_type, lhs, lhs_node);
|
||||
const rhs = try expr(gz, scope, .{ .rl = .{ .ty = log2_int_type }, .ctx = .shift_op }, rhs_node);
|
||||
|
||||
@ -117,6 +117,7 @@ test {
|
||||
_ = @import("behavior/bugs/13285.zig");
|
||||
_ = @import("behavior/bugs/13435.zig");
|
||||
_ = @import("behavior/bugs/13664.zig");
|
||||
_ = @import("behavior/bugs/13714.zig");
|
||||
_ = @import("behavior/byteswap.zig");
|
||||
_ = @import("behavior/byval_arg_var.zig");
|
||||
_ = @import("behavior/call.zig");
|
||||
|
||||
4
test/behavior/bugs/13714.zig
Normal file
4
test/behavior/bugs/13714.zig
Normal file
@ -0,0 +1,4 @@
|
||||
comptime {
|
||||
var image: [1]u8 = undefined;
|
||||
_ = @shlExact(@as(u16, image[0]), 8);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user