Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
96496105
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,发现更多精彩内容 >>
提交
96496105
编写于
5月 05, 2015
作者:
A
AlekseyTs
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Ensure error BC30053 is properly reported for field declarations.
Fixed #2424.
上级
6fdefaff
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
115 addition
and
12 deletion
+115
-12
src/Compilers/VisualBasic/Portable/Binding/Binder_Initializers.vb
...ilers/VisualBasic/Portable/Binding/Binder_Initializers.vb
+12
-8
src/Compilers/VisualBasic/Portable/Binding/Binder_Statements.vb
...mpilers/VisualBasic/Portable/Binding/Binder_Statements.vb
+7
-2
src/Compilers/VisualBasic/Test/Semantic/Binding/BindingErrorTests.vb
...rs/VisualBasic/Test/Semantic/Binding/BindingErrorTests.vb
+93
-2
src/Compilers/VisualBasic/Test/Semantic/Binding/BindingObjectInitializerTests.vb
...ic/Test/Semantic/Binding/BindingObjectInitializerTests.vb
+3
-0
未找到文件。
src/Compilers/VisualBasic/Portable/Binding/Binder_Initializers.vb
浏览文件 @
96496105
...
...
@@ -299,16 +299,20 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
diagnostics
)
Dim
hasErrors
=
False
If
fieldSymbols
.
Length
>
1
Then
' In speculative semantic model scenarios equalsValueOrAsNewSyntax might have no parent.
If
equalsValueOrAsNewSyntax
.
Parent
IsNot
Nothing
Then
Debug
.
Assert
(
fieldSymbols
.
Length
=
DirectCast
(
equalsValueOrAsNewSyntax
.
Parent
,
VariableDeclaratorSyntax
).
Names
.
Count
)
For
Each
name
In
DirectCast
(
equalsValueOrAsNewSyntax
.
Parent
,
VariableDeclaratorSyntax
).
Names
If
Not
(
name
.
ArrayRankSpecifiers
.
IsEmpty
AndAlso
name
.
ArrayBounds
Is
Nothing
)
Then
' Arrays cannot be declared with AsNew syntax
ReportDiagnostic
(
diagnostics
,
name
,
ERRID
.
ERR_AsNewArray
)
hasErrors
=
True
End
If
Next
If
equalsValueOrAsNewSyntax
.
Kind
()
=
SyntaxKind
.
AsNewClause
Then
For
Each
name
In
DirectCast
(
equalsValueOrAsNewSyntax
.
Parent
,
VariableDeclaratorSyntax
).
Names
If
Not
(
name
.
ArrayRankSpecifiers
.
IsEmpty
AndAlso
name
.
ArrayBounds
Is
Nothing
)
Then
' Arrays cannot be declared with AsNew syntax
ReportDiagnostic
(
diagnostics
,
name
,
ERRID
.
ERR_AsNewArray
)
hasErrors
=
True
End
If
Next
End
If
End
If
boundInitializers
.
Add
(
New
BoundFieldOrPropertyInitializer
(
...
...
src/Compilers/VisualBasic/Portable/Binding/Binder_Statements.vb
浏览文件 @
96496105
...
...
@@ -994,7 +994,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
#If DEBUG Then
For
i
=
0
To
names
.
Count
-
1
Debug
.
Assert
(
locals
(
i
).
InitializedByAsNew
)
Debug
.
Assert
(
locals
(
i
).
InitializerOpt
Is
Nothing
)
Debug
.
Assert
(
locals
(
i
).
InitializerOpt
Is
Nothing
OrElse
locals
(
i
).
InitializerOpt
.
Kind
=
BoundKind
.
BadExpression
)
Next
#End If
...
...
@@ -1170,7 +1170,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
If
name
.
ArrayBounds
IsNot
Nothing
Then
' It is an error to have both array bounds and an initializer expression
If
valueExpression
IsNot
Nothing
Then
ReportDiagnostic
(
diagnostics
,
name
,
ERRID
.
ERR_InitWithExplicitArraySizes
)
If
Not
isInitializedByAsNew
Then
ReportDiagnostic
(
diagnostics
,
name
,
ERRID
.
ERR_InitWithExplicitArraySizes
)
Else
' Must have reported ERR_AsNewArray already.
Debug
.
Assert
(
valueExpression
.
Kind
=
BoundKind
.
BadExpression
)
End
If
Else
valueExpression
=
New
BoundArrayCreation
(
name
,
boundArrayBounds
,
Nothing
,
type
)
End
If
...
...
src/Compilers/VisualBasic/Test/Semantic/Binding/BindingErrorTests.vb
浏览文件 @
96496105
...
...
@@ -1225,15 +1225,23 @@ BC30049: 'Redim' statement requires an array.
Diagnostic(ERRID.ERR_ArrayRankLimit, "(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33)"))
End Sub
<Fact
(
)>
Public Sub BC30053ERR_AsNewArray()
<Fact
, WorkItem(2424, "https://github.com/dotnet/roslyn/issues/2424"
)>
Public Sub BC30053ERR_AsNewArray
_01
()
Dim compilation1 = CompilationUtils.CreateCompilationWithMscorlibAndVBRuntime(
<compilation name="AsNewArray">
<file name="a.vb">
Module M1
Sub Foo()
Dim c() As New System.Exception
Dim d(), e() As New System.Exception
Dim f(), g As New System.Exception
Dim h, i() As New System.Exception
End Sub
Dim x() As New System.Exception
Dim y(), z() As New System.Exception
Dim u(), v As New System.Exception
Dim w, q() As New System.Exception
End Module
</file>
</compilation>)
...
...
@@ -1242,6 +1250,89 @@ BC30049: 'Redim' statement requires an array.
BC30053: Arrays cannot be declared with 'New'.
Dim c() As New System.Exception
~~~
BC30053: Arrays cannot be declared with 'New'.
Dim d(), e() As New System.Exception
~~~
BC30053: Arrays cannot be declared with 'New'.
Dim d(), e() As New System.Exception
~~~
BC30053: Arrays cannot be declared with 'New'.
Dim f(), g As New System.Exception
~~~
BC30053: Arrays cannot be declared with 'New'.
Dim h, i() As New System.Exception
~~~
BC30053: Arrays cannot be declared with 'New'.
Dim x() As New System.Exception
~~~
BC30053: Arrays cannot be declared with 'New'.
Dim y(), z() As New System.Exception
~~~
BC30053: Arrays cannot be declared with 'New'.
Dim y(), z() As New System.Exception
~~~
BC30053: Arrays cannot be declared with 'New'.
Dim u(), v As New System.Exception
~~~
BC30053: Arrays cannot be declared with 'New'.
Dim w, q() As New System.Exception
~~~
</errors>
CompilationUtils.AssertTheseDiagnostics(compilation1, expectedErrors1)
End Sub
<Fact, WorkItem(2424, "https://github.com/dotnet/roslyn/issues/2424")>
Public Sub BC30053ERR_AsNewArray_02()
Dim compilation1 = CompilationUtils.CreateCompilationWithMscorlibAndVBRuntime(
<compilation name="AsNewArray">
<file name="a.vb">
Module M1
Sub Foo()
Dim c(1) As New System.Exception
Dim d(1), e(1) As New System.Exception
Dim f(1), g As New System.Exception
Dim h, i(1) As New System.Exception
End Sub
Dim x(1) As New System.Exception
Dim y(1), z(1) As New System.Exception
Dim u(1), v As New System.Exception
Dim w, q(1) As New System.Exception
End Module
</file>
</compilation>)
Dim expectedErrors1 = <errors>
BC30053: Arrays cannot be declared with 'New'.
Dim c(1) As New System.Exception
~~~
BC30053: Arrays cannot be declared with 'New'.
Dim d(1), e(1) As New System.Exception
~~~
BC30053: Arrays cannot be declared with 'New'.
Dim d(1), e(1) As New System.Exception
~~~
BC30053: Arrays cannot be declared with 'New'.
Dim f(1), g As New System.Exception
~~~
BC30053: Arrays cannot be declared with 'New'.
Dim h, i(1) As New System.Exception
~~~
BC30053: Arrays cannot be declared with 'New'.
Dim x(1) As New System.Exception
~~~~
BC30053: Arrays cannot be declared with 'New'.
Dim y(1), z(1) As New System.Exception
~~~~
BC30053: Arrays cannot be declared with 'New'.
Dim y(1), z(1) As New System.Exception
~~~~
BC30053: Arrays cannot be declared with 'New'.
Dim u(1), v As New System.Exception
~~~~
BC30053: Arrays cannot be declared with 'New'.
Dim w, q(1) As New System.Exception
~~~~
</errors>
CompilationUtils.AssertTheseDiagnostics(compilation1, expectedErrors1)
End Sub
...
...
src/Compilers/VisualBasic/Test/Semantic/Binding/BindingObjectInitializerTests.vb
浏览文件 @
96496105
...
...
@@ -1315,6 +1315,9 @@ End Module
Dim
compilation
=
CompilationUtils
.
CreateCompilationWithMscorlibAndVBRuntime
(
source
)
AssertTheseDiagnostics
(
compilation
,
<
expected
>
BC30053
:
Arrays
cannot
be
declared
with
'New'.
Dim
b13
()
As
New
Integer
()
{
1
,
2
,
3
}
~~~~~
BC30205
:
End
of
statement
expected
.
Dim
b13
()
As
New
Integer
()
{
1
,
2
,
3
}
~
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录