-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
contributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.This issue is limited in scope and/or knowledge of Zig internals.enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.standard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.
Milestone
Description
zig version 0.4.0+fcc0728
The following is a fragment of code I have written that is currently formatted using zig fmt:
pub const IfSt = struct {
condition: Expression,
then_body: Block,
elseif_clauses: []const ElseifClause,
// TODO: else clause causes a compiler crash
// else_clause: ?ElseClause,
pub const Parser = comb.fluent //
.req("_", Leaf("KeyIf")) //
.req("condition", Expression).cut("Expected a boolean expression after `if`") //
.req("then_body", Block).cut("Expected a then-body after an if-condition") //
.star("elseif_clauses", ElseifClause) //
// .opt("else_clause", ElseClause) //
.seq(@This());
location: Location,
};Notice the drop in indentation starting with the final comment line, which also affects the following line. If the comment is removed, the next line is indented correctly.
While this style is probably unconventional for Zig, I find it a simple way to organize this kind of API, with one command per line, and without the noise of repeated struct literals. In any case, it's unfortunate that the indentation of subsequent lines of code is affected by the insertion of comments.
Metadata
Metadata
Assignees
Labels
contributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.This issue is limited in scope and/or knowledge of Zig internals.enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.standard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.