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

Extremely long error messages caused by slices into embedded file #20855

Open
ssmid opened this issue Jul 29, 2024 · 3 comments
Open

Extremely long error messages caused by slices into embedded file #20855

ssmid opened this issue Jul 29, 2024 · 3 comments
Labels
error message This issue points out an error message that is unhelpful and should be improved.
Milestone

Comments

@ssmid
Copy link
Contributor

ssmid commented Jul 29, 2024

Zig Version

0.14.0-dev.121+ab4c461b7

Steps to Reproduce and Observed Output

Shortened reproducer:

const std = @import("std");

pub fn main() void {
    comptime {
        const wayland_xml = XML.parse(wayland_xml_source);
        // some nonsense which causes an error message
        _ = try std.fmt.parseInt(u32, SomeType(wayland_xml.root().attribute(&wayland_xml, "name").?){}, 0);
    }
}

fn SomeType(some_string: []const u8) type {
    return struct {
        const s = some_string;
    };
}

pub const XML = struct {
[...]
};

const wayland_xml_source = \\<?xml version="1.0" encoding="UTF-8"?>
\\<protocol name="wayland">
\\
[...]
;

Error:

error_msg_repro.zig:7:101: error: expected type '[]const u8', found 'error_msg_repro.SomeType("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<protocol name=\"wayland\">\n\n  <copyright>\n    Copyright [...]
error_msg_repro.zig:12:12: note: struct declared here
~/bin/zig-0.14.0.121+ab4c461b7/lib/std/fmt.zig:1496:40: note: parameter type declared here

Everytime a slice of above xml file makes it into an error message, the whole file will be printed.
Currently, the error output in my project is above 1MB.

Full reproducer: https://zigbin.io/c06707

Expected Output

Just output the data within the slice, not the data of the underlying array, especially if it's big.
In above case this would be something along the lines of:

error: expected type '[]const u8', found 'error_msg_repro.SomeType("wayland")'
@ssmid ssmid added the error message This issue points out an error message that is unhelpful and should be improved. label Jul 29, 2024
@mlugg
Copy link
Member

mlugg commented Jul 29, 2024

Unclear reproduction. Steps to reproduce should not require the reader to guess at what library you're using, how you are using it, etc. Give the contents of all files and exact commands to run.

If you give a clear repro, ping me and I'll reopen.

@mlugg mlugg closed this as not planned Won't fix, can't repro, duplicate, stale Jul 29, 2024
@ssmid
Copy link
Contributor Author

ssmid commented Jul 29, 2024

@mlugg

@ssmid
Copy link
Contributor Author

ssmid commented Jul 29, 2024

I think the problem was pretty obvious before, but here you go.

@mlugg mlugg reopened this Jul 29, 2024
@Vexu Vexu added this to the 0.14.0 milestone Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error message This issue points out an error message that is unhelpful and should be improved.
Projects
None yet
Development

No branches or pull requests

3 participants