Zig Version
0.14.0-dev.2987+183bb8b08
Steps to Reproduce and Observed Output
I've hit this several times when debugging, but never realized when exactly it happened.
Most byte arrays (and pointers to them) passed to compileLog are formatted as text strings.
Yet for some reason, if they specifically hold more than one byte, and all bytes hold the same value, they are instead output as u8 integers.
Repro:
comptime {
@compileLog("\xFF"); //output as "\xff"
@compileLog("\xFF\xFE"); //output as "\xff\xfe"
@compileLog("\xFF\xFF"); //output as &.{ 255, 255 }
}
Output:
.zig:2:5: error: found compile log statement
@compileLog("\xFF"); //output as "\xff"
^~~~~~~~~~~~~~~~~~~
Compile Log Output:
@as(*const [1:0]u8, "\xff")
@as(*const [2:0]u8, "\xff\xfe")
@as(*const [2:0]u8, &.{ 255, 255 })
This behavior is so specific that it seems intentional, yet I don't understand the intention behind it.
When I sometimes randomly end up with both @compileLog("??"); and @compileLog("!!"); in my code, it's very unhelpful of the compiler to output these symbols as their ASCII values.
Expected Output
I would expect the text formatting that is used for most byte arrays to also apply to byte arrays of a single repeated value.
It's not a huge deal, but I think this behavior should eventually be changed to be more uniform.
Zig Version
0.14.0-dev.2987+183bb8b08
Steps to Reproduce and Observed Output
I've hit this several times when debugging, but never realized when exactly it happened.
Most byte arrays (and pointers to them) passed to
compileLogare formatted as text strings.Yet for some reason, if they specifically hold more than one byte, and all bytes hold the same value, they are instead output as u8 integers.
Repro:
Output:
This behavior is so specific that it seems intentional, yet I don't understand the intention behind it.
When I sometimes randomly end up with both
@compileLog("??");and@compileLog("!!");in my code, it's very unhelpful of the compiler to output these symbols as their ASCII values.Expected Output
I would expect the text formatting that is used for most byte arrays to also apply to byte arrays of a single repeated value.
It's not a huge deal, but I think this behavior should eventually be changed to be more uniform.