Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb29fe57

Browse files
Merge remote-tracking branch 'origin/master' into nameof-operator
2 parentsa732de0 +4abb633 commitb29fe57

File tree

6 files changed

+19
-14
lines changed

6 files changed

+19
-14
lines changed

‎src/fsharp/FSharp.Core/FSCore.resx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@
415415
<value>Type mismatch when building '{0}': function type doesn't match delegate type. Expected '{1}', but received type '{2}'.</value>
416416
</data>
417417
<dataname="QtmmRaw"xml:space="preserve">
418-
<value>Type mismatch when splicing expression into quotation literal. The type of the expression tree being inserted doesn't match the type expected by the splicing operation. Expected '{0}', but received type '{1}'. Consider type-annotating with the expected expression type, e.g., (%% x :string) or (%x :string).</value>
418+
<value>Type mismatch when splicing expression into quotation literal. The type of the expression tree being inserted doesn't match the type expected by the splicing operation. Expected '{0}', but received type '{1}'. Consider type-annotating with the expected expression type, e.g., (%% x :{0}) or (%x :{0}).</value>
419419
</data>
420420
<dataname="QtupleAccessOutOfRange"xml:space="preserve">
421421
<value>Tuple access out of range</value>

‎src/fsharp/TypeChecker.fs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4793,8 +4793,9 @@ and CrackStaticConstantArgs cenv env tpenv (staticParameters: Tainted<ProvidedPa
47934793
if not otherArgs.IsEmpty then
47944794
error (Error(FSComp.SR.etBadUnnamedStaticArgs(),m))
47954795

4796+
let indexedStaticParameters = staticParameters |> Array.toList |> List.indexed
47964797
for (n,_) in namedArgs do
4797-
matchstaticParameters |> Array.toList |> List.mapi (fun j x -> (j,x)) |> List.filter (fun (j,sp) -> j >= unnamedArgs.Length && n.idText = sp.PUntaint((fun sp -> sp.Name), m)) with
4798+
matchindexedStaticParameters |> List.filter (fun (j,sp) -> j >= unnamedArgs.Length && n.idText = sp.PUntaint((fun sp -> sp.Name), m)) with
47984799
| [] ->
47994800
if staticParameters |> Array.exists (fun sp -> n.idText = sp.PUntaint((fun sp -> sp.Name), n.idRange)) then
48004801
error (Error(FSComp.SR.etStaticParameterAlreadyHasValue n.idText,n.idRange))
@@ -5395,10 +5396,9 @@ and TcPat warnOnUpper cenv env topValInfo vFlags (tpenv,names,takenNames) ty pat
53955396
let ftys = fields |> List.map (fun fsp -> actualTyOfRecdField inst fsp,fsp)
53965397
let fldsmap',acc =
53975398
((tpenv,names,takenNames), ftys) ||> List.mapFold (fun s (ty,fsp) ->
5398-
if Map.containsKey fsp.rfield_id.idText fldsmap then
5399-
TcPat warnOnUpper cenv env None vFlags s ty (Map.find fsp.rfield_id.idText fldsmap)
5400-
else
5401-
(fun _ -> TPat_wild m),s)
5399+
match Map.tryFind fsp.rfield_id.idText fldsmap with
5400+
| Some v -> TcPat warnOnUpper cenv env None vFlags s ty v
5401+
| None -> (fun _ -> TPat_wild m),s)
54025402
(fun values -> TPat_recd (tcref,tinst,List.map (fun f -> f values) fldsmap',m)),
54035403
acc
54045404

‎src/fsharp/lexhelp.fs‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -342,12 +342,16 @@ module Keywords =
342342
|_->
343343
IdentifierToken args lexbuf s
344344

345+
let inlineprivateDoesIdentifierNeedQuotation(s:string):bool=
346+
not(String.forall IsIdentifierPartCharacter s)// if it has funky chars
347+
|| s.Length>0&&(not(IsIdentifierFirstCharacter s.[0]))// or if it starts with a non-(letter-or-underscore)
348+
|| keywordTable.ContainsKey s// or if it's a language keyword like "type"
349+
345350
/// A utility to help determine if an identifier needs to be quoted
346351
letQuoteIdentifierIfNeeded(s:string):string=
347-
ifnot(String.forall IsIdentifierPartCharacter s)// if it has funky chars
348-
|| s.Length>0&&(not(IsIdentifierFirstCharacter s.[0]))// or if it starts with a non-(letter-or-underscore)
349-
|| keywordTable.ContainsKey s// or if it's a language keyword like "type"
350-
then"``"+s+"``"// then it needs to be ``quoted``
351-
else s
352-
352+
if DoesIdentifierNeedQuotation sthen"``"+ s+"``"else s
353353

354+
/// Quote identifier with double backticks if needed, remove unnecessary double backticks quotation.
355+
letNormalizeIdentifierBackticks(s:string):string=
356+
lets=if s.StartsWith"``"&& s.EndsWith"``"then s.[2..s.Length-3]else s
357+
QuoteIdentifierIfNeeded s

‎src/fsharp/lexhelp.fsi‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,6 @@ module Keywords =
6767
valKeywordOrIdentifierToken:lexargs->UnicodeLexing.Lexbuf->string->Parser.token
6868
valIdentifierToken:lexargs->UnicodeLexing.Lexbuf->string->Parser.token
6969
valQuoteIdentifierIfNeeded:string->string
70+
valNormalizeIdentifierBackticks:string->string
7071
valkeywordNames:string list
7172
valkeywordTypes:Set<string>

‎tests/fsharpqa/Source/Conformance/Expressions/ExpressionQuotations/Regressions/E_QuotationHoles01.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ try
1212
exit1
1313
with
1414
|:? System.ArgumentExceptionas e->
15-
letexpected="Type mismatch when splicing expression into quotation literal. The type of the expression tree being inserted doesn't match the type expected by the splicing operation. Expected 'System.String', but received type 'System.Object'. Consider type-annotating with the expected expression type, e.g., (%% x :string) or (%x :string)."
15+
letexpected="Type mismatch when splicing expression into quotation literal. The type of the expression tree being inserted doesn't match the type expected by the splicing operation. Expected 'System.String', but received type 'System.Object'. Consider type-annotating with the expected expression type, e.g., (%% x :System.String) or (%x :System.String)."
1616
ifnot(e.Message.Contains(expected))then
1717
printfn"%A"(e.Message)
1818
exit1

‎vsintegration/src/FSharp.Editor/InlineRename/InlineRenameService.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ type internal InlineRenameInfo
105105
member__.DisplayName= symbolUse.Symbol.DisplayName
106106
member__.FullDisplayName=try symbolUse.Symbol.FullNamewith_-> symbolUse.Symbol.DisplayName
107107
member__.Glyph= Glyph.MethodPublic
108-
member__.GetFinalSymbolName replacementText= replacementText
108+
member__.GetFinalSymbolName replacementText=Lexhelp.Keywords.NormalizeIdentifierBackticksreplacementText
109109

110110
member__.GetReferenceEditSpan(location,cancellationToken)=
111111
lettext= getDocumentText location.Document cancellationToken

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp