| ... | @@ -302,13 +302,13 @@ pub fn format( | ... | @@ -302,13 +302,13 @@ pub fn format( |
| 302 | // Parse the width parameter | 302 | // Parse the width parameter |
| 303 | options.width = init: { | 303 | options.width = init: { |
| 304 | if (comptime parser.maybe('[')) { | 304 | if (comptime parser.maybe('[')) { |
| 305 | const arg_name = parser.until(']'); | 305 | const arg_name = comptime parser.until(']'); |
| 306 | | 306 | |
| 307 | if (!comptime parser.maybe(']')) { | 307 | if (!comptime parser.maybe(']')) { |
| 308 | @compileError("Expected closing ]"); | 308 | @compileError("Expected closing ]"); |
| 309 | } | 309 | } |
| 310 | | 310 | |
| 311 | const index = meta.fieldIndex(ArgsType, arg_name) orelse | 311 | const index = comptime meta.fieldIndex(ArgsType, arg_name) orelse |
| 312 | @compileError("No argument with name '" ++ arg_name ++ "'"); | 312 | @compileError("No argument with name '" ++ arg_name ++ "'"); |
| 313 | const arg_index = comptime arg_state.nextArg(index); | 313 | const arg_index = comptime arg_state.nextArg(index); |
| 314 | | 314 | |
| ... | @@ -328,13 +328,13 @@ pub fn format( | ... | @@ -328,13 +328,13 @@ pub fn format( |
| 328 | // Parse the precision parameter | 328 | // Parse the precision parameter |
| 329 | options.precision = init: { | 329 | options.precision = init: { |
| 330 | if (comptime parser.maybe('[')) { | 330 | if (comptime parser.maybe('[')) { |
| 331 | const arg_name = parser.until(']'); | 331 | const arg_name = comptime parser.until(']'); |
| 332 | | 332 | |
| 333 | if (!comptime parser.maybe(']')) { | 333 | if (!comptime parser.maybe(']')) { |
| 334 | @compileError("Expected closing ]"); | 334 | @compileError("Expected closing ]"); |
| 335 | } | 335 | } |
| 336 | | 336 | |
| 337 | const arg_i = meta.fieldIndex(ArgsType, arg_name) orelse | 337 | const arg_i = comptime meta.fieldIndex(ArgsType, arg_name) orelse |
| 338 | @compileError("No argument with name '" ++ arg_name ++ "'"); | 338 | @compileError("No argument with name '" ++ arg_name ++ "'"); |
| 339 | const arg_to_use = comptime arg_state.nextArg(arg_i); | 339 | const arg_to_use = comptime arg_state.nextArg(arg_i); |
| 340 | | 340 | |
| ... | @@ -2452,30 +2452,18 @@ test "type" { | ... | @@ -2452,30 +2452,18 @@ test "type" { |
| 2452 | } | 2452 | } |
| 2453 | | 2453 | |
| 2454 | test "named arguments" { | 2454 | test "named arguments" { |
| 2455 | if (true) { | | |
| 2456 | // TODO this regressed in the branch and I don't know why | | |
| 2457 | return error.SkipZigTest; | | |
| 2458 | } | | |
| 2459 | try expectFmt("hello world!", "{s} world{c}", .{ "hello", '!' }); | 2455 | try expectFmt("hello world!", "{s} world{c}", .{ "hello", '!' }); |
| 2460 | try expectFmt("hello world!", "{[greeting]s} world{[punctuation]c}", .{ .punctuation = '!', .greeting = "hello" }); | 2456 | try expectFmt("hello world!", "{[greeting]s} world{[punctuation]c}", .{ .punctuation = '!', .greeting = "hello" }); |
| 2461 | try expectFmt("hello world!", "{[1]s} world{[0]c}", .{ '!', "hello" }); | 2457 | try expectFmt("hello world!", "{[1]s} world{[0]c}", .{ '!', "hello" }); |
| 2462 | } | 2458 | } |
| 2463 | | 2459 | |
| 2464 | test "runtime width specifier" { | 2460 | test "runtime width specifier" { |
| 2465 | if (true) { | | |
| 2466 | // TODO this regressed in the branch and I don't know why | | |
| 2467 | return error.SkipZigTest; | | |
| 2468 | } | | |
| 2469 | var width: usize = 9; | 2461 | var width: usize = 9; |
| 2470 | try expectFmt("~~hello~~", "{s:~^[1]}", .{ "hello", width }); | 2462 | try expectFmt("~~hello~~", "{s:~^[1]}", .{ "hello", width }); |
| 2471 | try expectFmt("~~hello~~", "{s:~^[width]}", .{ .string = "hello", .width = width }); | 2463 | try expectFmt("~~hello~~", "{s:~^[width]}", .{ .string = "hello", .width = width }); |
| 2472 | } | 2464 | } |
| 2473 | | 2465 | |
| 2474 | test "runtime precision specifier" { | 2466 | test "runtime precision specifier" { |
| 2475 | if (true) { | | |
| 2476 | // TODO this regressed in the branch and I don't know why | | |
| 2477 | return error.SkipZigTest; | | |
| 2478 | } | | |
| 2479 | var number: f32 = 3.1415; | 2467 | var number: f32 = 3.1415; |
| 2480 | var precision: usize = 2; | 2468 | var precision: usize = 2; |
| 2481 | try expectFmt("3.14e+00", "{:1.[1]}", .{ number, precision }); | 2469 | try expectFmt("3.14e+00", "{:1.[1]}", .{ number, precision }); |