From 6cf15f4ea1fe044d8227440dcc30ac712334568e Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 27 Feb 2025 10:32:14 -0800 Subject: Allow `.member` syntax on vector and scalars. (#6424) * Allow `.member` syntax on vector and scalars. * Fix. * fix. * Fix. * update comment. * Fix tests. * Fix warning. * Add more tests. --- source/slang/slang-check-overload.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'source/slang/slang-check-overload.cpp') diff --git a/source/slang/slang-check-overload.cpp b/source/slang/slang-check-overload.cpp index 5e55eb70f..21fc21df6 100644 --- a/source/slang/slang-check-overload.cpp +++ b/source/slang/slang-check-overload.cpp @@ -1316,15 +1316,17 @@ int SemanticsVisitor::CompareLookupResultItems( // Add a special case for constructors, where we prefer the one that is not synthesized, if (auto leftCtor = as(left.declRef.getDecl())) { - auto rightCtor = as(right.declRef.getDecl()); - bool leftIsSynthesized = - leftCtor->containsFlavor(ConstructorDecl::ConstructorFlavor::SynthesizedDefault); - bool rightIsSynthesized = - rightCtor->containsFlavor(ConstructorDecl::ConstructorFlavor::SynthesizedDefault); - - if (leftIsSynthesized != rightIsSynthesized) + if (auto rightCtor = as(right.declRef.getDecl())) { - return int(leftIsSynthesized) - int(rightIsSynthesized); + bool leftIsSynthesized = leftCtor->containsFlavor( + ConstructorDecl::ConstructorFlavor::SynthesizedDefault); + bool rightIsSynthesized = rightCtor->containsFlavor( + ConstructorDecl::ConstructorFlavor::SynthesizedDefault); + + if (leftIsSynthesized != rightIsSynthesized) + { + return int(leftIsSynthesized) - int(rightIsSynthesized); + } } } -- cgit v1.2.3