authorchloe caruso <git@paperclover.net> 2024-07-27 05:11:48-07:00
committerchloe caruso <git@paperclover.net> 2024-07-27 05:11:48-07:00
log438a43d6761f19cb71d1d0928fe76b8734888ee0
treee70a588d10c9511b3ad9ad80ffee3dc8bfed8cde
parent2768b7a704977ffc4c1eefaafddc548b42aec0e4

fix hex literal warning


2 files changed, 10 insertions(+), 1 deletions(-)

CHANGELOG.md+1
......@@ -7,6 +7,7 @@
77- fix(sema): fix passing structs as function params
88- fix: diagnostic box drawing characters line up after line 9
99- fix: diagnostics on last line of file print correctly
10- fix: diagnostics with the leading zero warning
1011
1112## 0.1.4
1213
src/core/Transform.zig+9-1
......@@ -881,7 +881,15 @@ fn transformExpression(
881881 else => @compileError(unreachable),
882882 };
883883
884 if (value != 0 and text[0] == '0' and (text.len == 1 or text[1] != '.')) {
884 const has_zero_prefix = value != 0 and
885 text[0] == '0' and
886 (text.len == 1 or switch (tag) {
887 .number_int => text[1] >= '0' and text[1] < '9',
888 .number_float => text[1] != '.',
889 else => @compileError(unreachable),
890 });
891
892 if (has_zero_prefix) {
885893 try t.report.warn(.zero_prefixed_literal, .{ .token = t.ast.nodeToken(node) });
886894 }
887895