From 4c33987ebb62145ded4db381625483d7d0abe2fa Mon Sep 17 00:00:00 2001 From: Fredric Silberberg Date: Tue, 1 Oct 2024 10:20:45 -0700 Subject: [PATCH] PR feedback. --- .../CSharp/Portable/Binder/Binder_Patterns.cs | 7 ++++--- src/Compilers/CSharp/Test/EndToEnd/EndToEndTests.cs | 12 +++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Patterns.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Patterns.cs index 6a885bcc9944b..9755a4667ff09 100644 --- a/src/Compilers/CSharp/Portable/Binder/Binder_Patterns.cs +++ b/src/Compilers/CSharp/Portable/Binder/Binder_Patterns.cs @@ -1758,7 +1758,8 @@ private BoundPattern BindBinaryPattern( result = bindBinaryPattern( result, this, - binaryPatternAndPermitDesignations, + binaryPatternAndPermitDesignations.pat, + binaryPatternAndPermitDesignations.permitDesignations, inputType, narrowedTypeCandidates, hasErrors, @@ -1772,13 +1773,13 @@ private BoundPattern BindBinaryPattern( static BoundPattern bindBinaryPattern( BoundPattern preboundLeft, Binder binder, - (BinaryPatternSyntax pat, bool permitDesignations) patternAndPermitDesignations, + BinaryPatternSyntax node, + bool permitDesignations, TypeSymbol inputType, ArrayBuilder narrowedTypeCandidates, bool hasErrors, BindingDiagnosticBag diagnostics) { - (BinaryPatternSyntax node, bool permitDesignations) = patternAndPermitDesignations; bool isDisjunction = node.Kind() == SyntaxKind.OrPattern; if (isDisjunction) { diff --git a/src/Compilers/CSharp/Test/EndToEnd/EndToEndTests.cs b/src/Compilers/CSharp/Test/EndToEnd/EndToEndTests.cs index 35af6d168f4b5..f1febfb5c79bc 100644 --- a/src/Compilers/CSharp/Test/EndToEnd/EndToEndTests.cs +++ b/src/Compilers/CSharp/Test/EndToEnd/EndToEndTests.cs @@ -726,17 +726,19 @@ class XAttribute : System.Attribute { } step => Assert.True(step.Outputs.Single().Value is ClassDeclarationSyntax { Identifier.ValueText: "C1" })); } - [Fact] - public void ManyBinaryPatterns() + [Theory] + [InlineData("or", "1")] + [InlineData("and not", "0")] + public void ManyBinaryPatterns(string pattern, string expectedOutput) { const string preamble = $""" int i = 2; System.Console.Write(i is """; - const string append = $""" + string append = $""" - or + {pattern} """; const string postscript = """ @@ -764,7 +766,7 @@ public void ManyBinaryPatterns() RunInThread(() => { var comp = CreateCompilation(source, options: TestOptions.DebugExe.WithConcurrentBuild(false)); - CompileAndVerify(comp, expectedOutput: "1"); + CompileAndVerify(comp, expectedOutput: expectedOutput); var tree = comp.SyntaxTrees[0]; var isPattern = tree.GetRoot().DescendantNodes().OfType().Single();