Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

u8 local variable while debugging shows as string #381

Open
redexp opened this issue Jan 18, 2025 · 3 comments
Open

u8 local variable while debugging shows as string #381

redexp opened this issue Jan 18, 2025 · 3 comments

Comments

@redexp
Copy link

redexp commented Jan 18, 2025

Good day

Example code

const std = @import("std");
const expect = std.testing.expect;

test "while with continue expression" {
    var sum: u8 = 0;
    var i: u8 = 1;
    while (i <= 10) : (i += 1) {
        sum += i;
        std.debug.print("{d}", .{i});
    }
    try expect(sum == 55);
}

on step 4 debug toolbar shows variables like this

i = '\x04'
sum = '\n'

when should be

i = 4
sum = 10

vscode-zig version

Identifier: ziglang.vscode-zig
Version: 0.6.3
Last Updated: 2025-01-17, 17:59:21

VScode version

Version: 1.96.4
Commit: cd4ee3b1c348a13bafd8f9ad8060705f6d4b9cba
Date: 2025-01-16T00:16:19.038Z
Electron: 32.2.6
ElectronBuildId: 10629634
Chromium: 128.0.6613.186
Node.js: 20.18.1
V8: 12.8.374.38-electron.0
OS: Linux x64 6.8.0-51-generic snap
@redexp
Copy link
Author

redexp commented Jan 18, 2025

Oh, I got it, u8 is used for char and extension thinks that nobody will use it as number? I just started learning zig

@Vexu
Copy link
Member

Vexu commented Jan 18, 2025

That would be the debuggers fault, I'm not sure how much the extension can do to control that and it probably shouldn't since a lot of times you want u8 to be printed as a character. When using lldb in the terminal you can use frame variable --format d sum to print sum as an integer but I'm not sure how that is done in the GUI.

@redexp
Copy link
Author

redexp commented Jan 19, 2025

It's obvious to me to make an assumption on how the variable was declared. with quotes or with a number. If it's too complicated, the issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants