tomlplusplus icon indicating copy to clipboard operation
tomlplusplus copied to clipboard

Fail to build when imported from a module unit purview

Open wroyca opened this issue 3 years ago • 0 comments

— This problem is reported here more as a backlog than as a real problem. It shouldn't really concern people who don't use state-of-the-art compilers with C++ modules. Nevertheless, @marzer asked me to flag it as a problem to look into at some point.


Commit: c6deadf61db048feda3998041af8021244368671

Compiler:
Microsoft Visual C++ 14.32.31326 / May 10, 2022

C++ standard mode:
23

Target arch:
x64

tomlplusplus will flag C2872 should we try to use it when it is imported from a module unit purview:

import <sstream>;
import <iostream>;

export module uniform; // purview begin...
import "toml.hpp";     // import inside uniform's purview...

using namespace std::string_view_literals;

int main()
{
  static constexpr std::string_view some_toml = R"(
    [library]
    name = "toml++"
    authors = ["Mark Gillard <[email protected]>"]
    cpp = 17
  )"sv;

  try
  {
    // parse directly from a string view:
    {
      toml::table tbl = toml::parse(some_toml);
      std::cout << tbl << "\n";
    }

    // parse from a string stream:
    {
      std::stringstream ss{ std::string{ some_toml } };
      toml::table tbl = toml::parse(ss); // Error! C2872!
      std::cout << tbl << "\n";
    }
  }
  catch (const toml::parse_error& err)
  {
    std::cerr << "Parsing failed:\n" << err << "\n";
    return 1;
  }

  return 0;
}
> Error C2079 'toml::v3::impl::impl_ex::parser::root' uses undefined class 'toml::v3::table'

wroyca avatar Sep 13 '22 04:09 wroyca