D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 23600 - [std.format.read] formattedRead static asserts with Tuple and compile time format string
Summary: [std.format.read] formattedRead static asserts with Tuple and compile time fo...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2023-01-04 21:32 UTC by João Lourenço
Modified: 2023-01-05 20:18 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description João Lourenço 2023-01-04 21:32:40 UTC
```d
import std;

void main()
{
    Tuple!(int, float) t;
    "1 2.34".formattedRead!"%d %f"(t);
}
```

This code sample static asserts but correctly runs when passing the format string at run time. This happens because the format check is performed on the Tuple type instead of its Types.
Comment 1 Dlang Bot 2023-01-04 21:52:09 UTC
@iK4tsu updated dlang/phobos pull request #8661 "Fix: [std.format.read] formattedRead static asserts with Tuple and compile time format string" fixing this issue:

- fix(format.read): formattedRead incorrectly static asserts with Tuple and compile-time format string
  
  This method supports std.typecons.Tuple, however, when passing the
  format string at compile-time, the format validation does not correctly
  account for the std.typecons.Tuple's types and instead validates the
  std.typecons.Tuple itself leading to a static assert.
  
  This change now adds support for this feature when used with
  compile-time format strings.
  
  Fix Issue #23600
  
  Signed-off-by: João Lourenço <jlourenco5691@gmail.com>

https://github.com/dlang/phobos/pull/8661
Comment 2 Dlang Bot 2023-01-05 20:18:36 UTC
dlang/phobos pull request #8661 "Fix: [std.format.read] formattedRead static asserts with Tuple and compile time format string" was merged into master:

- c4192e855e4fefe6e40e62d7994decce47d21fa1 by João Lourenço:
  fix(format.read): formattedRead incorrectly static asserts with Tuple and compile-time format string
  
  This method supports std.typecons.Tuple, however, when passing the
  format string at compile-time, the format validation does not correctly
  account for the std.typecons.Tuple's types and instead validates the
  std.typecons.Tuple itself leading to a static assert.
  
  This change now adds support for this feature when used with
  compile-time format strings.
  
  Fix Issue #23600
  
  Signed-off-by: João Lourenço <jlourenco5691@gmail.com>

https://github.com/dlang/phobos/pull/8661