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

Use-as-a-library footgun: Diagnostics.errors is only set during rendering #603

Open
squeek502 opened this issue Dec 17, 2023 · 0 comments
Open
Labels
bug Something isn't working

Comments

@squeek502
Copy link
Contributor

squeek502 commented Dec 17, 2023

Diagnostics.errors is only modified within Diagnostics.renderMessages:

comp.diagnostics.errors += errors;


Driver always calls render before checking errors, so it's not hit by this:

arocc/src/aro/Driver.zig

Lines 621 to 626 in 7dd1575

d.renderErrors();
if (d.comp.diagnostics.errors != 0) {
if (fast_exit) std.process.exit(1); // Not linking, no need for cleanup.
return;
}

but I only want to render errors if there was an actual error, so I attempted this:

    try pp.preprocessSources(&.{ source, builtin_macros, user_macros });

    if (comp.diagnostics.errors != 0) {
        return error.FatalError;
    }

and was confused as to why errors was still 0 after a preprocessing error had definitely occurred.

@Vexu Vexu added the bug Something isn't working label Dec 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants