Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
fsharp
提交
5a5a5f6c
F
fsharp
项目概览
dotNET Platform
/
fsharp
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
未验证
提交
5a5a5f6c
编写于
6月 27, 2022
作者:
F
Florian Verdonck
提交者:
GitHub
6月 27, 2022
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add arrow to SynType.Fun trivia. (#13375)
上级
900a0c58
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
55 addition
and
12 deletion
+55
-12
src/Compiler/Checking/CheckDeclarations.fs
src/Compiler/Checking/CheckDeclarations.fs
+1
-1
src/Compiler/Checking/CheckExpressions.fs
src/Compiler/Checking/CheckExpressions.fs
+1
-1
src/Compiler/Service/ServiceParseTreeWalk.fs
src/Compiler/Service/ServiceParseTreeWalk.fs
+1
-1
src/Compiler/Service/ServiceParsedInputOps.fs
src/Compiler/Service/ServiceParsedInputOps.fs
+2
-2
src/Compiler/SyntaxTree/SyntaxTree.fs
src/Compiler/SyntaxTree/SyntaxTree.fs
+1
-1
src/Compiler/SyntaxTree/SyntaxTree.fsi
src/Compiler/SyntaxTree/SyntaxTree.fsi
+1
-1
src/Compiler/SyntaxTree/SyntaxTrivia.fs
src/Compiler/SyntaxTree/SyntaxTrivia.fs
+3
-0
src/Compiler/SyntaxTree/SyntaxTrivia.fsi
src/Compiler/SyntaxTree/SyntaxTrivia.fsi
+8
-0
src/Compiler/pars.fsy
src/Compiler/pars.fsy
+5
-3
tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected
...s/FSharp.CompilerService.SurfaceArea.netstandard.expected
+8
-1
tests/service/ServiceUntypedParseTests.fs
tests/service/ServiceUntypedParseTests.fs
+1
-1
tests/service/Symbols.fs
tests/service/Symbols.fs
+23
-0
未找到文件。
src/Compiler/Checking/CheckDeclarations.fs
浏览文件 @
5a5a5f6c
...
...
@@ -5091,7 +5091,7 @@ module TcDeclarations =
memberFlags
.
MemberKind
=
SynMemberKind
.
Constructor
&&
// REVIEW: This is a syntactic approximation
(
match
synValSig
.
SynType
,
synValSig
.
SynInfo
.
CurriedArgInfos
with
|
StripParenTypes
(
SynType
.
Fun
(
StripParenTypes
(
SynType
.
LongIdent
(
SynLongIdent
([
id
],
_,
_))),
_,
_
)),
[[_]]
when
id
.
idText
=
"unit"
->
true
|
StripParenTypes
(
SynType
.
Fun
(
argType
=
StripParenTypes
(
SynType
.
LongIdent
(
SynLongIdent
([
id
],
_,
_)))
)),
[[_]]
when
id
.
idText
=
"unit"
->
true
|
_
->
false
)
|
_
->
false
)
...
...
src/Compiler/Checking/CheckExpressions.fs
浏览文件 @
5a5a5f6c
...
...
@@ -4537,7 +4537,7 @@ and TcTypeOrMeasure kindOpt cenv newOk checkConstraints occ env (tpenv: Unscoped
| SynType.AnonRecd(isStruct, args, m) ->
TcAnonRecdType cenv newOk checkConstraints occ env tpenv isStruct args m
| SynType.Fun(
domainTy, resultTy, _
) ->
| SynType.Fun(
argType = domainTy; returnType = resultTy
) ->
TcFunctionType cenv newOk checkConstraints occ env tpenv domainTy resultTy
| SynType.Array (rank , elemTy, m) ->
...
...
src/Compiler/Service/ServiceParseTreeWalk.fs
浏览文件 @
5a5a5f6c
...
...
@@ -807,7 +807,7 @@ module SyntaxTraversal =
|
SynType
.
App
(
typeName
,
_,
typeArgs
,
_,
_,
_,
_)
|
SynType
.
LongIdentApp
(
typeName
,
_,
_,
typeArgs
,
_,
_,
_)
->
[
yield
typeName
;
yield
!
typeArgs
]
|>
List
.
tryPick
(
traverseSynType
path
)
|
SynType
.
Fun
(
ty1
,
ty2
,
_
)
->
[
ty1
;
ty2
]
|>
List
.
tryPick
(
traverseSynType
path
)
|
SynType
.
Fun
(
argType
=
ty1
;
returnType
=
ty2
)
->
[
ty1
;
ty2
]
|>
List
.
tryPick
(
traverseSynType
path
)
|
SynType
.
MeasurePower
(
ty
,
_,
_)
|
SynType
.
HashConstraint
(
ty
,
_)
|
SynType
.
WithGlobalConstraints
(
ty
,
_,
_)
...
...
src/Compiler/Service/ServiceParsedInputOps.fs
浏览文件 @
5a5a5f6c
...
...
@@ -663,7 +663,7 @@ module ParsedInput =
|
SynType
.
LongIdentApp
(_,
_,
_,
types
,
_,
_,
_)
->
List
.
tryPick
walkType
types
|
SynType
.
Tuple
(_,
ts
,
_)
->
ts
|>
List
.
tryPick
(
fun
(_,
t
)
->
walkType
t
)
|
SynType
.
Array
(_,
t
,
_)
->
walkType
t
|
SynType
.
Fun
(
t1
,
t2
,
_
)
->
walkType
t1
|>
Option
.
orElseWith
(
fun
()
->
walkType
t2
)
|
SynType
.
Fun
(
argType
=
t1
;
returnType
=
t2
)
->
walkType
t1
|>
Option
.
orElseWith
(
fun
()
->
walkType
t2
)
|
SynType
.
WithGlobalConstraints
(
t
,
_,
_)
->
walkType
t
|
SynType
.
HashConstraint
(
t
,
_)
->
walkType
t
|
SynType
.
MeasureDivide
(
t1
,
t2
,
_)
->
walkType
t1
|>
Option
.
orElseWith
(
fun
()
->
walkType
t2
)
...
...
@@ -1651,7 +1651,7 @@ module ParsedInput =
|
SynType
.
HashConstraint
(
t
,
_)
|
SynType
.
MeasurePower
(
t
,
_,
_)
|
SynType
.
Paren
(
t
,
_)
->
walkType
t
|
SynType
.
Fun
(
t1
,
t2
,
_
)
|
SynType
.
Fun
(
argType
=
t1
;
returnType
=
t2
)
|
SynType
.
MeasureDivide
(
t1
,
t2
,
_)
->
walkType
t1
walkType
t2
...
...
src/Compiler/SyntaxTree/SyntaxTree.fs
浏览文件 @
5a5a5f6c
...
...
@@ -398,7 +398,7 @@ type SynType =
|
Array
of
rank
:
int
*
elementType
:
SynType
*
range
:
range
|
Fun
of
argType
:
SynType
*
returnType
:
SynType
*
range
:
range
|
Fun
of
argType
:
SynType
*
returnType
:
SynType
*
range
:
range
*
trivia
:
SynTypeFunTrivia
|
Var
of
typar
:
SynTypar
*
range
:
range
...
...
src/Compiler/SyntaxTree/SyntaxTree.fsi
浏览文件 @
5a5a5f6c
...
...
@@ -471,7 +471,7 @@ type SynType =
|
Array
of
rank
:
int
*
elementType
:
SynType
*
range
:
range
/// F# syntax: type -> type
|
Fun
of
argType
:
SynType
*
returnType
:
SynType
*
range
:
range
|
Fun
of
argType
:
SynType
*
returnType
:
SynType
*
range
:
range
*
trivia
:
SynTypeFunTrivia
/// F# syntax: 'Var
|
Var
of
typar
:
SynTypar
*
range
:
range
...
...
src/Compiler/SyntaxTree/SyntaxTrivia.fs
浏览文件 @
5a5a5f6c
...
...
@@ -230,3 +230,6 @@ type SynValSigTrivia =
WithKeyword
=
None
EqualsRange
=
None
}
[<
NoEquality
;
NoComparison
>]
type
SynTypeFunTrivia
=
{
ArrowRange
:
range
}
src/Compiler/SyntaxTree/SyntaxTrivia.fsi
浏览文件 @
5a5a5f6c
...
...
@@ -324,3 +324,11 @@ type SynValSigTrivia =
}
static
member
Zero
:
SynValSigTrivia
/// Represents additional information for SynType.Fun
[<
NoEquality
;
NoComparison
>]
type
SynTypeFunTrivia
=
{
/// The syntax range of the `->` token.
ArrowRange
:
range
}
src/Compiler/pars.fsy
浏览文件 @
5a5a5f6c
...
...
@@ -4993,8 +4993,9 @@ opt_topReturnTypeWithTypeConstraints:
topType:
| topTupleType RARROW topType
{ let dty, dmdata= $1
let rty, (SynValInfo(dmdatas, rmdata)) = $3
SynType.Fun(dty, rty, lhs parseState), (SynValInfo(dmdata :: dmdatas, rmdata)) }
let rty, (SynValInfo(dmdatas, rmdata)) = $3
let mArrow = rhs parseState 2
SynType.Fun(dty, rty, lhs parseState, { ArrowRange = mArrow }), (SynValInfo(dmdata :: dmdatas, rmdata)) }
| topTupleType
{ let ty, rmdata = $1 in ty, (SynValInfo([], (match rmdata with [md] -> md | _ -> SynInfo.unnamedRetVal))) }
...
...
@@ -5040,7 +5041,8 @@ topAppType:
/* See the F# specification "Lexical analysis of type applications and type parameter definitions" */
typ:
| tupleType RARROW typ
{ SynType.Fun($1, $3, lhs parseState) }
{ let mArrow = rhs parseState 2
SynType.Fun($1, $3, lhs parseState, { ArrowRange = mArrow }) }
| tupleType %prec prec_typ_prefix
{ $1 }
...
...
tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected
浏览文件 @
5a5a5f6c
...
...
@@ -8408,6 +8408,8 @@ FSharp.Compiler.Syntax.SynType+Fun: FSharp.Compiler.Syntax.SynType argType
FSharp.Compiler.Syntax.SynType+Fun: FSharp.Compiler.Syntax.SynType get_argType()
FSharp.Compiler.Syntax.SynType+Fun: FSharp.Compiler.Syntax.SynType get_returnType()
FSharp.Compiler.Syntax.SynType+Fun: FSharp.Compiler.Syntax.SynType returnType
FSharp.Compiler.Syntax.SynType+Fun: FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia get_trivia()
FSharp.Compiler.Syntax.SynType+Fun: FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia trivia
FSharp.Compiler.Syntax.SynType+Fun: FSharp.Compiler.Text.Range get_range()
FSharp.Compiler.Syntax.SynType+Fun: FSharp.Compiler.Text.Range range
FSharp.Compiler.Syntax.SynType+HashConstraint: FSharp.Compiler.Syntax.SynType get_innerType()
...
...
@@ -8531,7 +8533,7 @@ FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewAnon(FSharp.Co
FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewAnonRecd(Boolean, Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[FSharp.Compiler.Syntax.Ident,FSharp.Compiler.Syntax.SynType]], FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewApp(FSharp.Compiler.Syntax.SynType, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Boolean, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewArray(Int32, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewFun(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewFun(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range
, FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia
)
FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewHashConstraint(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewLongIdent(FSharp.Compiler.Syntax.SynLongIdent)
FSharp.Compiler.Syntax.SynType: FSharp.Compiler.Syntax.SynType NewLongIdentApp(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Syntax.SynLongIdent, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.SynType], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], FSharp.Compiler.Text.Range)
...
...
@@ -9463,6 +9465,11 @@ FSharp.Compiler.SyntaxTrivia.SynTypeDefnTrivia: Microsoft.FSharp.Core.FSharpOpti
FSharp.Compiler.SyntaxTrivia.SynTypeDefnTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_WithKeyword()
FSharp.Compiler.SyntaxTrivia.SynTypeDefnTrivia: System.String ToString()
FSharp.Compiler.SyntaxTrivia.SynTypeDefnTrivia: Void .ctor(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range])
FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia
FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia: FSharp.Compiler.Text.Range ArrowRange
FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia: FSharp.Compiler.Text.Range get_ArrowRange()
FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia: System.String ToString()
FSharp.Compiler.SyntaxTrivia.SynTypeFunTrivia: Void .ctor(FSharp.Compiler.Text.Range)
FSharp.Compiler.SyntaxTrivia.SynUnionCaseTrivia
FSharp.Compiler.SyntaxTrivia.SynUnionCaseTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] BarRange
FSharp.Compiler.SyntaxTrivia.SynUnionCaseTrivia: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.Range] get_BarRange()
...
...
tests/service/ServiceUntypedParseTests.fs
浏览文件 @
5a5a5f6c
...
...
@@ -152,7 +152,7 @@ let rec getParenTypes (synType: SynType): SynType list =
yield
synType
yield
!
getParenTypes
innerType
|
SynType
.
Fun
(
argType
,
returnType
,
_
)
->
|
SynType
.
Fun
(
argType
=
argType
;
returnType
=
returnType
)
->
yield
!
getParenTypes
argType
yield
!
getParenTypes
returnType
...
...
tests/service/Symbols.fs
浏览文件 @
5a5a5f6c
...
...
@@ -4699,3 +4699,26 @@ module Measures =
Assert
.
AreEqual
(
"weeks"
,
weeksIdent
.
idText
)
assertRange
(
2
,
9
)
(
2
,
22
)
mParen
|
_
->
Assert
.
Fail
$
"Could not get valid AST, got {parseResults}"
module
SyntaxTypes
=
[<
Test
>]
let
``SynType.Fun has range of arrow``
()
=
let
parseResults
=
getParseResults
"""
type X = string -> // after a tuple, mixed needs an indent
int
"""
match
parseResults
with
|
ParsedInput
.
ImplFile
(
ParsedImplFileInput
(
modules
=
[
SynModuleOrNamespace
.
SynModuleOrNamespace
(
decls
=
[
SynModuleDecl
.
Types
(
typeDefns
=
[
SynTypeDefn
(
typeRepr
=
SynTypeDefnRepr
.
Simple
(
simpleRepr
=
SynTypeDefnSimpleRepr
.
TypeAbbrev
(
rhsType
=
SynType
.
Fun
(
trivia
=
{
ArrowRange
=
mArrow
}))))
])
])
]))
->
assertRange
(
2
,
21
)
(
2
,
23
)
mArrow
|
_
->
Assert
.
Fail
$
"Could not get valid AST, got {parseResults}"
麦壳饼
@mysticboy
mentioned in commit
4567458a
·
7月 25, 2022
mentioned in commit
4567458a
mentioned in commit 4567458a502c6a7741d3320df9f4a686e4ae651f
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录