Skip to content

Improve error message when encountering a trailing character in source code #14188

@zxubian

Description

@zxubian

Zig Version

0.11.0-dev.945+0c30e006c

Steps to Reproduce and Observed Output

Both of the following examples produce an unhelpful error message:

const std = @import("std");
pub fn main() !void {
    std.log.info("Hello, World!", .{});
} w

repro.zig:1:1: error: tuple declarations cannot contain declarations
const std = @import("std");
^~~~~~~~~~~~~~~~~~~~~~~~~~

test "Empty"{

} w

repro.zig:1:1: error: tuple declarations cannot contain declarations
test "Empty" {
^~~~

Expected Output

Expected a more helpful error message, e.g.:

error: unexpected character 'w'
} w
~~^~~~~~~~~~~~~~~~~~~~~~~~~~

Error message should correctly point to the incorrect character/symbol/token.

Metadata

Metadata

Assignees

No one assigned

    Labels

    error messageThis issue points out an error message that is unhelpful and should be improved.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions