Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
4d749695
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
4d749695
编写于
9月 24, 2019
作者:
R
Rikki Gibson
提交者:
GitHub
9月 24, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix TakeIncrementalSnapshot crash (#38752)
上级
712a1ca8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
63 addition
and
0 deletion
+63
-0
src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs
src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs
+3
-0
src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs
...rp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs
+60
-0
未找到文件。
src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs
浏览文件 @
4d749695
...
...
@@ -5786,6 +5786,9 @@ public override BoundNode VisitAssignmentOperator(BoundAssignmentOperator node)
var
left
=
node
.
Left
;
var
right
=
node
.
Right
;
VisitLValue
(
left
);
// we may enter a conditional state for error scenarios on the LHS.
Unsplit
();
FlowAnalysisAnnotations
leftAnnotations
=
GetLValueAnnotations
(
left
);
TypeWithAnnotations
declaredType
=
LvalueResultType
;
TypeWithAnnotations
leftLValueType
=
ApplyLValueAnnotations
(
declaredType
,
leftAnnotations
);
...
...
src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs
浏览文件 @
4d749695
...
...
@@ -104672,6 +104672,66 @@ public class Broken<T> : IEnumerable<IEquatable<T>> where T : class
comp.VerifyDiagnostics();
}
[Fact, WorkItem(37868, "https://github.com/dotnet/roslyn/issues/37868")]
public void IsPatternVariableDeclaration_LeftOfAssignmentOperator()
{
var source = @"
using System;
class C
{
void Test1()
{
if (unknown is string b = )
{
Console.WriteLine(b);
}
}
void Test2(bool a)
{
if (a is bool (b = a))
{
Console.WriteLine(b);
}
}
}
";
var comp = CreateNullableCompilation(source);
comp.VerifyDiagnostics(
// (8,13): error CS0103: The name 'unknown' does not exist in the current context
// if (unknown is string b = )
Diagnostic(ErrorCode.ERR_NameNotInContext, "unknown").WithArguments("unknown").WithLocation(8, 13),
// (8,35): error CS1525: Invalid expression term ')'
// if (unknown is string b = )
Diagnostic(ErrorCode.ERR_InvalidExprTerm, ")").WithArguments(")").WithLocation(8, 35),
// (10,31): error CS0165: Use of unassigned local variable 'b'
// Console.WriteLine(b);
Diagnostic(ErrorCode.ERR_UseDefViolation, "b").WithArguments("b").WithLocation(10, 31),
// (16,23): error CS8129: No suitable 'Deconstruct' instance or extension method was found for type 'bool', with 1 out parameters and a void return type.
// if (a is bool (b = a))
Diagnostic(ErrorCode.ERR_MissingDeconstruct, "(b ").WithArguments("bool", "1").WithLocation(16, 23),
// (16,24): error CS0103: The name 'b' does not exist in the current context
// if (a is bool (b = a))
Diagnostic(ErrorCode.ERR_NameNotInContext, "b").WithArguments("b").WithLocation(16, 24),
// (16,26): error CS1026: ) expected
// if (a is bool (b = a))
Diagnostic(ErrorCode.ERR_CloseParenExpected, "=").WithLocation(16, 26),
// (16,30): error CS1525: Invalid expression term ')'
// if (a is bool (b = a))
Diagnostic(ErrorCode.ERR_InvalidExprTerm, ")").WithArguments(")").WithLocation(16, 30),
// (16,30): error CS1002: ; expected
// if (a is bool (b = a))
Diagnostic(ErrorCode.ERR_SemicolonExpected, ")").WithLocation(16, 30),
// (16,30): error CS1513: } expected
// if (a is bool (b = a))
Diagnostic(ErrorCode.ERR_RbraceExpected, ")").WithLocation(16, 30),
// (18,31): error CS0103: The name 'b' does not exist in the current context
// Console.WriteLine(b);
Diagnostic(ErrorCode.ERR_NameNotInContext, "b").WithArguments("b").WithLocation(18, 31));
}
[WorkItem(30140, "https://github.com/dotnet/roslyn/issues/30140")]
[Fact]
public void NullCoalescingAssignment_UseInExpression()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录