Thanks to visit codestin.com
Credit goes to github.com

Skip to content

zig fmt takes exponential time to render nested arrays/tuples with trailing commas #10194

@chadwain

Description

@chadwain

Zig Version

0.9.0-dev.1678+7747bf07c

Steps to Reproduce

Run zig fmt on this sequence of inputs.

  • const x = .{.{},};
  • const x = .{.{.{},},};
  • const x = .{.{.{.{},},},};

or

  • const x = T{T{},};
  • const x = T{T{T{},},};
  • const x = T{T{T{T{},},},};
  • And so on...

Expected Behavior

Formatter goes fast

Actual Behavior

Each iteration takes twice as long as the previous. It takes about 20 iterations to get to 1 second execution time. Deleting the commas fixes this problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorcontributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.optimizationzig fmt

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions