Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly handle expression variable declared within VariableDeclaratorSyntax.ArgumentList in field declarations. #13564

Merged
merged 2 commits into from
Sep 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Compilers/CSharp/Portable/CSharpResources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Compilers/CSharp/Portable/CSharpResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -4948,6 +4948,6 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<value>Deconstruction is not supported for an 'out' argument.</value>
</data>
<data name="ERR_ExpressionVariableInConstructorOrFieldInitializer" xml:space="preserve">
<value>Out variable or pattern variable declarations are not allowed within constructor/field/auto-implemented property initializers.</value>
<value>Out variable and pattern variable declarations are not allowed within constructor initializers, field initializers, or property initializers.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public sealed override int FixedSize
ExpressionSyntax sizeExpression = arguments[0].Expression;

BinderFactory binderFactory = this.DeclaringCompilation.GetBinderFactory(SyntaxTree);
Binder binder = binderFactory.GetBinder(sizeExpression);
Binder binder = new ExpressionVariableBinder(sizeExpression, binderFactory.GetBinder(sizeExpression));

TypeSymbol intType = binder.GetSpecialType(SpecialType.System_Int32, diagnostics, sizeExpression);
BoundExpression boundSizeExpression = binder.GenerateConversionForAssignment(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Roslyn.Utilities;
Expand Down Expand Up @@ -153,7 +154,9 @@ internal static LocalSymbol MakeLocalSymbolWithEnclosingContext(
Debug.Assert(
nodeToBind.Kind() == SyntaxKind.CasePatternSwitchLabel ||
nodeToBind.Kind() == SyntaxKind.ArgumentList && nodeToBind.Parent is ConstructorInitializerSyntax ||
nodeToBind.Kind() == SyntaxKind.VariableDeclarator ||
nodeToBind.Kind() == SyntaxKind.VariableDeclarator &&
new[] { SyntaxKind.LocalDeclarationStatement, SyntaxKind.ForStatement, SyntaxKind.UsingStatement, SyntaxKind.FixedStatement }.
Contains(nodeToBind.Ancestors().OfType<StatementSyntax>().First().Kind()) ||
nodeToBind is ExpressionSyntax);
return typeSyntax.IsVar
? new LocalSymbolWithEnclosingContext(containingSy