Skip to content

Fix single element tuple like handling#71

Open
yaito3014 wants to merge 53 commits intomainfrom
fix-single-element-tuple-like-handling
Open

Fix single element tuple like handling#71
yaito3014 wants to merge 53 commits intomainfrom
fix-single-element-tuple-like-handling

Conversation

@yaito3014
Copy link
Member

@yaito3014 yaito3014 commented Mar 7, 2026

fixes #18
based on iris-cpp/iris#54
supersedes #42

Todo

Post-merge todo (split these into separate issues, then check)

@cppwarningnotifier

This comment has been minimized.

@yaito3014 yaito3014 requested a review from saki7 March 7, 2026 05:56
@yaito3014 yaito3014 self-assigned this Mar 7, 2026
@saki7
Copy link
Member

saki7 commented Mar 8, 2026

Still not working for my scripting engine, the failing case is:

constexpr auto name_path_def = /* please insert a suitable definition based on the type definition below */;
constexpr auto any_id_def = name_path; // <------ error
constexpr auto any_id_def = as<NamePath>(name_path); // <------ ok

where the attribute types are

struct Ident { /* same as existing test case */ };

// Represents a qualified name,
// e.g. `foo::bar` is {false, {"foo", "bar"}}
// e.g. `::foo::bar` is {true, {"foo", "bar"}}
struct NamePath // adapted
{
    bool is_rooted = false;
    std::vector<Ident> segments;
};

struct AnyID // adapted
{
    NamePath path;
};

@cppwarningnotifier

This comment has been minimized.

@cppwarningnotifier

This comment has been minimized.

@cppwarningnotifier

This comment has been minimized.

@cppwarningnotifier

This comment has been minimized.

@cppwarningnotifier

This comment has been minimized.

Comment on lines +181 to +192
auto&& unwrapped_attr = [&]() -> decltype(auto) {
if constexpr (traits::is_single_element_tuple_like<RHSAttr>::value) {
if constexpr (traits::can_hold<typename parser_traits<RHS>::attribute_type, alloy::tuple_element_t<0, RHSAttr>>::value) {
return alloy::get<0>(rhs_attr);
} else {
return rhs_attr;
}
} else {
return rhs_attr;
}
}();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to emit static_assert to prohibit narrowing conversion case. We want to make such case hard error as per "X3 rule problem".

@cppwarningnotifier
Copy link

EnvironmentC++23C++26
x4Clang21Debug✅success✅success
Release✅success✅success
GCC14Debug✅success✅success
Release✅success✅success
MSVC2022Debug✅success✅success
Release✅success✅success
2026Debug✅success✅success
Release✅success✅success

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Single element tuple-like needs to be eliminated from user-facing API

2 participants