diff --git a/src/Compilers/CSharp/Portable/CSharpResources.resx b/src/Compilers/CSharp/Portable/CSharpResources.resx index 3dc91256b2b83..6f03520e938fb 100644 --- a/src/Compilers/CSharp/Portable/CSharpResources.resx +++ b/src/Compilers/CSharp/Portable/CSharpResources.resx @@ -5230,6 +5230,9 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ An expression tree may not contain a throw-expression. + + An expression tree may not contain a with-expression. + Invalid assembly name: {0} diff --git a/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs b/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs index 496fa9a5b0222..b1d7aa14df632 100644 --- a/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs +++ b/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs @@ -1818,6 +1818,7 @@ internal enum ErrorCode ERR_CannotConvertAddressOfToDelegate = 8811, ERR_AddressOfToNonFunctionPointer = 8812, + ERR_ExpressionTreeContainsWithExpression = 8849, ERR_BadRecordDeclaration = 8850, ERR_DuplicateRecordConstructor = 8851, ERR_AssignmentInitOnly = 8852, diff --git a/src/Compilers/CSharp/Portable/Lowering/DiagnosticsPass_ExpressionTrees.cs b/src/Compilers/CSharp/Portable/Lowering/DiagnosticsPass_ExpressionTrees.cs index 17878195bd824..7067c4eaa38a5 100644 --- a/src/Compilers/CSharp/Portable/Lowering/DiagnosticsPass_ExpressionTrees.cs +++ b/src/Compilers/CSharp/Portable/Lowering/DiagnosticsPass_ExpressionTrees.cs @@ -860,5 +860,15 @@ public override BoundNode VisitThrowExpression(BoundThrowExpression node) return base.VisitThrowExpression(node); } + + public override BoundNode VisitWithExpression(BoundWithExpression node) + { + if (_inExpressionLambda) + { + Error(ErrorCode.ERR_ExpressionTreeContainsWithExpression, node); + } + + return base.VisitWithExpression(node); + } } } diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf index cb8ae00e53d7a..cfa7405d4d041 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf @@ -312,6 +312,11 @@ Strom výrazů nesmí obsahovat operátor řazené kolekce členů == nebo !=. + + An expression tree may not contain a with-expression. + An expression tree may not contain a with-expression. + + '{0}': extern event cannot have initializer {0}: Externí událost nemůže mít inicializátor. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf index 1eec6bb07f753..460d9873fb499 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf @@ -312,6 +312,11 @@ Eine Ausdrucksbaumstruktur darf keinen ==- oder !=-Tupeloperator enthalten. + + An expression tree may not contain a with-expression. + An expression tree may not contain a with-expression. + + '{0}': extern event cannot have initializer "{0}": Externes Ereignis darf keinen Initialisierer aufweisen. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf index 87013d35769f6..6486056efe930 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf @@ -312,6 +312,11 @@ Un árbol de expresión no puede contener un operador de tupla == o !=. + + An expression tree may not contain a with-expression. + An expression tree may not contain a with-expression. + + '{0}': extern event cannot have initializer "{0}": un evento externo no puede tener un inicializador diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf index 267da2bf78f42..bbb9c0f9d66c5 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf @@ -312,6 +312,11 @@ Une arborescence de l'expression ne peut pas contenir un opérateur de tuple == ou != + + An expression tree may not contain a with-expression. + An expression tree may not contain a with-expression. + + '{0}': extern event cannot have initializer '{0}' : un événement extern ne peut pas avoir d'initialiseur diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf index 5c66bfbb6fad6..cec129d23e64f 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf @@ -312,6 +312,11 @@ Un albero delle espressioni non può contenere un operatore == o != di tupla + + An expression tree may not contain a with-expression. + An expression tree may not contain a with-expression. + + '{0}': extern event cannot have initializer '{0}': l'evento extern non può avere inizializzatori diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf index 1ce4645e28c3f..3b70e105571da 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf @@ -312,6 +312,11 @@ 式ツリーにタプルの == または != 演算子を含めることはできません + + An expression tree may not contain a with-expression. + An expression tree may not contain a with-expression. + + '{0}': extern event cannot have initializer '{0}': extern イベントは初期化子を持つことができません diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf index e1288e3b47b37..c4a9c6b448e66 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf @@ -312,6 +312,11 @@ 식 트리에는 튜플 == 또는 != 연산자를 사용할 수 없습니다. + + An expression tree may not contain a with-expression. + An expression tree may not contain a with-expression. + + '{0}': extern event cannot have initializer '{0}': extern 이벤트에는 이니셜라이저를 사용할 수 없습니다. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf index 3b4a2d428096b..d7cabe3c9b46c 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf @@ -312,6 +312,11 @@ Drzewo wyrażenia nie może zawierać operatora == ani != krotki. + + An expression tree may not contain a with-expression. + An expression tree may not contain a with-expression. + + '{0}': extern event cannot have initializer '„{0}”: zdarzenie extern nie może mieć inicjatora diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf index c08aea3759945..56467e3542041 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf @@ -312,6 +312,11 @@ Uma árvore de expressão não pode conter um operador == ou != de tupla + + An expression tree may not contain a with-expression. + An expression tree may not contain a with-expression. + + '{0}': extern event cannot have initializer '{0}': o evento externo não pode ter inicializador diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf index b71df5fde3119..df99918b9ede2 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf @@ -312,6 +312,11 @@ Дерево выражений не может содержать оператор == или != кортежа. + + An expression tree may not contain a with-expression. + An expression tree may not contain a with-expression. + + '{0}': extern event cannot have initializer "{0}": внешнее событие не может иметь инициализатор diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf index 71286ed2418ac..b792395ea25e7 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf @@ -312,6 +312,11 @@ İfade ağacı, demetin == veya != işlecini içeremez. + + An expression tree may not contain a with-expression. + An expression tree may not contain a with-expression. + + '{0}': extern event cannot have initializer '{0}': dış etkinliğin başlatıcısı olamaz diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf index b9cdde0c4dc84..535c4ae115df7 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf @@ -312,6 +312,11 @@ 表达式树不能包含元组 == 或 != 运算符 + + An expression tree may not contain a with-expression. + An expression tree may not contain a with-expression. + + '{0}': extern event cannot have initializer “{0}”: 外部事件不能有初始值设定项 diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf index 0293eaf68bc9f..6cd161c1afede 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf @@ -312,6 +312,11 @@ 運算式樹狀架構不得包含元組 == 或 != 運算子。 + + An expression tree may not contain a with-expression. + An expression tree may not contain a with-expression. + + '{0}': extern event cannot have initializer '{0}': 外部事件不可有初始設定式 diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/RecordTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/RecordTests.cs index eaf032799bd68..362ff2e321d86 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/RecordTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/RecordTests.cs @@ -145,6 +145,27 @@ record Point(int x, int y); comp.VerifyDiagnostics(); } + [Fact] + public void TestInExpressionTree() + { + var source = @" +using System; +using System.Linq.Expressions; +public record C(int i) +{ + public static void M() + { + Expression> expr = c => c with { i = 5 }; + } +}"; + var comp = CreateCompilation(source); + comp.VerifyDiagnostics( + // (8,44): error CS8849: An expression tree may not contain a with-expression. + // Expression> expr = c => c with { i = 5 }; + Diagnostic(ErrorCode.ERR_ExpressionTreeContainsWithExpression, "c with { i = 5 }").WithLocation(8, 44) + ); + } + [Fact] public void PartialRecordMixedWithClass() {