Skip to content

Printing with leading newline breaks build test output #15576

@ieeemma

Description

@ieeemma

Zig Version

0.11.0-dev.2969+855493bb8

Steps to Reproduce and Observed Behavior

const std = @import("std");

pub fn main() void {}

test {
    std.debug.print("\nNew line!\n", .{});
    return error.ThisIsAnError;
}

Put this in a blank zig project and run zig build test. This causes this output:

run test: error: 'test_0' failed: New line!
/home/emma/zig-bugs/newline/src/main.zig:7:5: 0x20efe9 in test_0 (test)
    return error.ThisIsAnError;
    ^
run test: error: m

First, the leading newline before the message is stripped, and second an erroneous run test: error: m is printed.

Expected Behavior

Expected an output like this:

run test: error: 'test_0' failed:
New line!
/home/emma/zig-bugs/newline/src/main.zig:7:5: 0x20efe9 in test_0 (test)
    return error.ThisIsAnError;
    ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions