Skip to content

Commit

Permalink
PR feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
333fred committed Oct 1, 2024
1 parent 4d5160d commit 4c33987
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
7 changes: 4 additions & 3 deletions src/Compilers/CSharp/Portable/Binder/Binder_Patterns.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1758,7 +1758,8 @@ private BoundPattern BindBinaryPattern(
result = bindBinaryPattern(
result,
this,
binaryPatternAndPermitDesignations,
binaryPatternAndPermitDesignations.pat,
binaryPatternAndPermitDesignations.permitDesignations,
inputType,
narrowedTypeCandidates,
hasErrors,
Expand All @@ -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<TypeSymbol> narrowedTypeCandidates,
bool hasErrors,
BindingDiagnosticBag diagnostics)
{
(BinaryPatternSyntax node, bool permitDesignations) = patternAndPermitDesignations;
bool isDisjunction = node.Kind() == SyntaxKind.OrPattern;
if (isDisjunction)
{
Expand Down
12 changes: 7 additions & 5 deletions src/Compilers/CSharp/Test/EndToEnd/EndToEndTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = """
Expand Down Expand Up @@ -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<IsPatternExpressionSyntax>().Single();
Expand Down

0 comments on commit 4c33987

Please sign in to comment.