Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
fsharp
提交
e9c26ff2
F
fsharp
项目概览
dotNET Platform
/
fsharp
12 个月 前同步成功
通知
0
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
fsharp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
e9c26ff2
编写于
2月 07, 2022
作者:
F
Florian Verdonck
提交者:
GitHub
2月 07, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Correct Range for SynExprAndBang (#12680)
* Correct range for SynExprAndBang. * Add trivia for SynExprAndBang.
上级
1fd98f46
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
88 addition
and
13 deletion
+88
-13
src/fsharp/SyntaxTree.fs
src/fsharp/SyntaxTree.fs
+2
-2
src/fsharp/SyntaxTree.fsi
src/fsharp/SyntaxTree.fsi
+2
-2
src/fsharp/SyntaxTrivia.fs
src/fsharp/SyntaxTrivia.fs
+5
-0
src/fsharp/SyntaxTrivia.fsi
src/fsharp/SyntaxTrivia.fsi
+10
-0
src/fsharp/pars.fsy
src/fsharp/pars.fsy
+5
-4
tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected
...s/FSharp.CompilerService.SurfaceArea.netstandard.expected
+10
-3
tests/service/Symbols.fs
tests/service/Symbols.fs
+54
-2
未找到文件。
src/fsharp/SyntaxTree.fs
浏览文件 @
e9c26ff2
...
@@ -953,9 +953,9 @@ type SynExprAndBang =
...
@@ -953,9 +953,9 @@ type SynExprAndBang =
isUse
:
bool
*
isUse
:
bool
*
isFromSource
:
bool
*
isFromSource
:
bool
*
pat
:
SynPat
*
pat
:
SynPat
*
equalsRange
:
range
*
body
:
SynExpr
*
body
:
SynExpr
*
range
:
range
range
:
range
*
trivia
:
SynExprAndBangTrivia
[<
NoEquality
;
NoComparison
>]
[<
NoEquality
;
NoComparison
>]
type
SynExprRecordField
=
type
SynExprRecordField
=
...
...
src/fsharp/SyntaxTree.fsi
浏览文件 @
e9c26ff2
...
@@ -1066,9 +1066,9 @@ type SynExprAndBang =
...
@@ -1066,9 +1066,9 @@ type SynExprAndBang =
isUse
:
bool
*
isUse
:
bool
*
isFromSource
:
bool
*
isFromSource
:
bool
*
pat
:
SynPat
*
pat
:
SynPat
*
equalsRange
:
range
*
body
:
SynExpr
*
body
:
SynExpr
*
range
:
range
range
:
range
*
trivia
:
SynExprAndBangTrivia
[<
NoEquality
;
NoComparison
>]
[<
NoEquality
;
NoComparison
>]
type
SynExprRecordField
=
type
SynExprRecordField
=
...
...
src/fsharp/SyntaxTrivia.fs
浏览文件 @
e9c26ff2
...
@@ -81,3 +81,8 @@ type SynMemberFlagsTrivia =
...
@@ -81,3 +81,8 @@ type SynMemberFlagsTrivia =
AbstractRange
=
None
AbstractRange
=
None
StaticRange
=
None
StaticRange
=
None
DefaultRange
=
None
}
DefaultRange
=
None
}
[<
NoEquality
;
NoComparison
>]
type
SynExprAndBangTrivia
=
{
EqualsRange
:
range
InKeyword
:
range
option
}
src/fsharp/SyntaxTrivia.fsi
浏览文件 @
e9c26ff2
...
@@ -138,3 +138,13 @@ type SynMemberFlagsTrivia =
...
@@ -138,3 +138,13 @@ type SynMemberFlagsTrivia =
DefaultRange
:
range
option
DefaultRange
:
range
option
}
}
static
member
Zero
:
SynMemberFlagsTrivia
static
member
Zero
:
SynMemberFlagsTrivia
/// Represents additional information for SynExprAndBang
[<
NoEquality
;
NoComparison
>]
type
SynExprAndBangTrivia
=
{
/// The syntax range of the `=` token.
EqualsRange
:
range
/// The syntax range of the `in` keyword.
InKeyword
:
range
option
}
src/fsharp/pars.fsy
浏览文件 @
e9c26ff2
...
@@ -3600,16 +3600,17 @@ moreBinders:
...
@@ -3600,16 +3600,17 @@ moreBinders:
| AND_BANG headBindingPattern EQUALS typedSequentialExprBlock IN moreBinders %prec expr_let
| AND_BANG headBindingPattern EQUALS typedSequentialExprBlock IN moreBinders %prec expr_let
{ let spBind = DebugPointAtBinding.Yes(rhs2 parseState 1 5) (* TODO Pretty sure this is wrong *)
{ let spBind = DebugPointAtBinding.Yes(rhs2 parseState 1 5) (* TODO Pretty sure this is wrong *)
let mEquals = rhs parseState 3
let mEquals = rhs parseState 3
let m = rhs parseState 1 (* TODO Pretty sure this is wrong *)
let m = unionRanges (rhs parseState 1) $4.Range
SynExprAndBang(spBind, $1, true, $2, mEquals, $4, m) :: $6 }
let mIn = rhs parseState 5
SynExprAndBang(spBind, $1, true, $2, $4, m, { EqualsRange = mEquals; InKeyword = Some mIn }) :: $6 }
| OAND_BANG headBindingPattern EQUALS typedSequentialExprBlock hardwhiteDefnBindingsTerminator opt_OBLOCKSEP moreBinders %prec expr_let
| OAND_BANG headBindingPattern EQUALS typedSequentialExprBlock hardwhiteDefnBindingsTerminator opt_OBLOCKSEP moreBinders %prec expr_let
{ let report, mIn = $5
{ let report, mIn = $5
report "and!" (rhs parseState 1) // report unterminated error
report "and!" (rhs parseState 1) // report unterminated error
let spBind = DebugPointAtBinding.Yes(rhs2 parseState 1 5) (* TODO Pretty sure this is wrong *)
let spBind = DebugPointAtBinding.Yes(rhs2 parseState 1 5) (* TODO Pretty sure this is wrong *)
let mEquals = rhs parseState 3
let mEquals = rhs parseState 3
let m =
rhs parseState 1 (* TODO Pretty sure this is wrong *)
let m =
unionRanges (rhs parseState 1) $4.Range
SynExprAndBang(spBind, $1, true, $2,
mEquals, $4, m
) :: $7 }
SynExprAndBang(spBind, $1, true, $2,
$4, m, { EqualsRange = mEquals; InKeyword = mIn }
) :: $7 }
| %prec prec_no_more_attr_bindings
| %prec prec_no_more_attr_bindings
{ [] }
{ [] }
...
...
tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected
浏览文件 @
e9c26ff2
...
@@ -7052,11 +7052,11 @@ FSharp.Compiler.Syntax.SynExprAndBang: FSharp.Compiler.Syntax.DebugPointAtBindin
...
@@ -7052,11 +7052,11 @@ FSharp.Compiler.Syntax.SynExprAndBang: FSharp.Compiler.Syntax.DebugPointAtBindin
FSharp.Compiler.Syntax.SynExprAndBang: FSharp.Compiler.Syntax.DebugPointAtBinding get_debugPoint()
FSharp.Compiler.Syntax.SynExprAndBang: FSharp.Compiler.Syntax.DebugPointAtBinding get_debugPoint()
FSharp.Compiler.Syntax.SynExprAndBang: FSharp.Compiler.Syntax.SynExpr body
FSharp.Compiler.Syntax.SynExprAndBang: FSharp.Compiler.Syntax.SynExpr body
FSharp.Compiler.Syntax.SynExprAndBang: FSharp.Compiler.Syntax.SynExpr get_body()
FSharp.Compiler.Syntax.SynExprAndBang: FSharp.Compiler.Syntax.SynExpr get_body()
FSharp.Compiler.Syntax.SynExprAndBang: FSharp.Compiler.Syntax.SynExprAndBang NewSynExprAndBang(FSharp.Compiler.Syntax.DebugPointAtBinding, Boolean, Boolean, FSharp.Compiler.Syntax.SynPat, FSharp.Compiler.
Text.Range, FSharp.Compiler.Syntax.SynExpr, FSharp.Compiler.Text.Range
)
FSharp.Compiler.Syntax.SynExprAndBang: FSharp.Compiler.Syntax.SynExprAndBang NewSynExprAndBang(FSharp.Compiler.Syntax.DebugPointAtBinding, Boolean, Boolean, FSharp.Compiler.Syntax.SynPat, FSharp.Compiler.
Syntax.SynExpr, FSharp.Compiler.Text.Range, FSharp.Compiler.SyntaxTrivia.SynExprAndBangTrivia
)
FSharp.Compiler.Syntax.SynExprAndBang: FSharp.Compiler.Syntax.SynPat get_pat()
FSharp.Compiler.Syntax.SynExprAndBang: FSharp.Compiler.Syntax.SynPat get_pat()
FSharp.Compiler.Syntax.SynExprAndBang: FSharp.Compiler.Syntax.SynPat pat
FSharp.Compiler.Syntax.SynExprAndBang: FSharp.Compiler.Syntax.SynPat pat
FSharp.Compiler.Syntax.SynExprAndBang: FSharp.Compiler.
Text.Range equalsRange
FSharp.Compiler.Syntax.SynExprAndBang: FSharp.Compiler.
SyntaxTrivia.SynExprAndBangTrivia get_trivia()
FSharp.Compiler.Syntax.SynExprAndBang: FSharp.Compiler.
Text.Range get_equalsRange()
FSharp.Compiler.Syntax.SynExprAndBang: FSharp.Compiler.
SyntaxTrivia.SynExprAndBangTrivia trivia
FSharp.Compiler.Syntax.SynExprAndBang: FSharp.Compiler.Text.Range get_range()
FSharp.Compiler.Syntax.SynExprAndBang: FSharp.Compiler.Text.Range get_range()
FSharp.Compiler.Syntax.SynExprAndBang: FSharp.Compiler.Text.Range range
FSharp.Compiler.Syntax.SynExprAndBang: FSharp.Compiler.Text.Range range
FSharp.Compiler.Syntax.SynExprAndBang: Int32 Tag
FSharp.Compiler.Syntax.SynExprAndBang: Int32 Tag
...
@@ -9077,6 +9077,13 @@ FSharp.Compiler.SyntaxTrivia.SynEnumCaseTrivia: Microsoft.FSharp.Core.FSharpOpti
...
@@ -9077,6 +9077,13 @@ FSharp.Compiler.SyntaxTrivia.SynEnumCaseTrivia: Microsoft.FSharp.Core.FSharpOpti
FSharp.Compiler.SyntaxTrivia.SynEnumCaseTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_BarRange()
FSharp.Compiler.SyntaxTrivia.SynEnumCaseTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_BarRange()
FSharp.Compiler.SyntaxTrivia.SynEnumCaseTrivia: System.String ToString()
FSharp.Compiler.SyntaxTrivia.SynEnumCaseTrivia: System.String ToString()
FSharp.Compiler.SyntaxTrivia.SynEnumCaseTrivia: Void .ctor(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], FSharp.Compiler.Text.Range)
FSharp.Compiler.SyntaxTrivia.SynEnumCaseTrivia: Void .ctor(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], FSharp.Compiler.Text.Range)
FSharp.Compiler.SyntaxTrivia.SynExprAndBangTrivia
FSharp.Compiler.SyntaxTrivia.SynExprAndBangTrivia: FSharp.Compiler.Text.Range EqualsRange
FSharp.Compiler.SyntaxTrivia.SynExprAndBangTrivia: FSharp.Compiler.Text.Range get_EqualsRange()
FSharp.Compiler.SyntaxTrivia.SynExprAndBangTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] InKeyword
FSharp.Compiler.SyntaxTrivia.SynExprAndBangTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_InKeyword()
FSharp.Compiler.SyntaxTrivia.SynExprAndBangTrivia: System.String ToString()
FSharp.Compiler.SyntaxTrivia.SynExprAndBangTrivia: Void .ctor(FSharp.Compiler.Text.Range, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range])
FSharp.Compiler.SyntaxTrivia.SynExprIfThenElseTrivia
FSharp.Compiler.SyntaxTrivia.SynExprIfThenElseTrivia
FSharp.Compiler.SyntaxTrivia.SynExprIfThenElseTrivia: Boolean IsElif
FSharp.Compiler.SyntaxTrivia.SynExprIfThenElseTrivia: Boolean IsElif
FSharp.Compiler.SyntaxTrivia.SynExprIfThenElseTrivia: Boolean get_IsElif()
FSharp.Compiler.SyntaxTrivia.SynExprIfThenElseTrivia: Boolean get_IsElif()
...
...
tests/service/Symbols.fs
浏览文件 @
e9c26ff2
...
@@ -703,7 +703,7 @@ comp {
...
@@ -703,7 +703,7 @@ comp {
SynModuleDecl
.
DoExpr
(
expr
=
SynExpr
.
App
(
argExpr
=
SynModuleDecl
.
DoExpr
(
expr
=
SynExpr
.
App
(
argExpr
=
SynExpr
.
ComputationExpr
(
expr
=
SynExpr
.
ComputationExpr
(
expr
=
SynExpr
.
LetOrUseBang
(
equalsRange
=
Some
mLetBangEquals
SynExpr
.
LetOrUseBang
(
equalsRange
=
Some
mLetBangEquals
andBangs
=
[
SynExprAndBang
(
equalsRange
=
mAndBangEquals
)
]))))
andBangs
=
[
SynExprAndBang
(
trivia
=
{
EqualsRange
=
mAndBangEquals
}
)
]))))
])
])
]))
->
]))
->
assertRange
(
3
,
11
)
(
3
,
12
)
mLetBangEquals
assertRange
(
3
,
11
)
(
3
,
12
)
mLetBangEquals
...
@@ -3246,4 +3246,56 @@ let meh =
...
@@ -3246,4 +3246,56 @@ let meh =
assertRange
(
7
,
8
)
(
7
,
14
)
mMember3
assertRange
(
7
,
8
)
(
7
,
14
)
mMember3
|
_
->
|
_
->
Assert
.
Fail
"Could not get valid AST"
Assert
.
Fail
"Could not get valid AST"
\ No newline at end of file
module
ComputationExpressions
=
[<
Test
>]
let
``SynExprAndBang range starts at and! and ends after expression``
()
=
let
ast
=
getParseResults
"""
async {
let! bar = getBar ()
and! foo = getFoo ()
return bar
}
"""
match
ast
with
|
ParsedInput
.
ImplFile
(
ParsedImplFileInput
(
modules
=
[
SynModuleOrNamespace
.
SynModuleOrNamespace
(
decls
=
[
SynModuleDecl
.
DoExpr
(
expr
=
SynExpr
.
App
(
argExpr
=
SynExpr
.
ComputationExpr
(
expr
=
SynExpr
.
LetOrUseBang
(
andBangs
=
[
SynExprAndBang
(
range
=
mAndBang
)
]))))
])
]))
->
assertRange
(
5
,
4
)
(
5
,
24
)
mAndBang
|
_
->
Assert
.
Fail
"Could not get valid AST"
[<
Test
>]
let
``multiple SynExprAndBang have range that starts at and! and ends after expression``
()
=
let
ast
=
getParseResults
"""
async {
let! bar = getBar ()
and! foo = getFoo () in
and! meh = getMeh ()
return bar
}
"""
match
ast
with
|
ParsedInput
.
ImplFile
(
ParsedImplFileInput
(
modules
=
[
SynModuleOrNamespace
.
SynModuleOrNamespace
(
decls
=
[
SynModuleDecl
.
DoExpr
(
expr
=
SynExpr
.
App
(
argExpr
=
SynExpr
.
ComputationExpr
(
expr
=
SynExpr
.
LetOrUseBang
(
andBangs
=
[
SynExprAndBang
(
range
=
mAndBang1
;
trivia
={
InKeyword
=
Some
mIn
})
SynExprAndBang
(
range
=
mAndBang2
)
]))))
])
]))
->
assertRange
(
4
,
4
)
(
4
,
24
)
mAndBang1
assertRange
(
4
,
25
)
(
4
,
27
)
mIn
assertRange
(
5
,
4
)
(
5
,
24
)
mAndBang2
|
_
->
Assert
.
Fail
"Could not get valid AST"
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录