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

Commit5acc100

Browse files
committed
Better wording
1 parent6abbbf5 commit5acc100

File tree

5 files changed

+35
-16
lines changed

5 files changed

+35
-16
lines changed

‎src/fsharp/CompileOps.fs‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,10 @@ let GetRangeOfDiagnostic(err:PhasedDiagnostic) =
203203
| SelfRefObjCtor(_,m)->
204204
Some m
205205

206-
| NotAFunction(_,_,_,mfun,_)->
206+
| NotAFunction(_,_,mfun,_)->
207+
Some mfun
208+
209+
| NotAFunctionButIndexer(_,_,_,mfun,_)->
207210
Some mfun
208211

209212
| IllegalFileNameChar(_)-> Some rangeCmdArgs
@@ -243,7 +246,7 @@ let GetDiagnosticNumber(err:PhasedDiagnostic) =
243246
(* DO NOT CHANGE THESE NUMBERS*)
244247
| ErrorFromAddingTypeEquation_->1
245248
| FunctionExpected_->2
246-
|NotAFunction(_,_,true,_,_)->3217
249+
|NotAFunctionButIndexer_->3217
247250
| NotAFunction_->3
248251
| FieldNotMutable_->5
249252
| Recursion_->6
@@ -742,14 +745,15 @@ let OutputPhasedErrorR (os:StringBuilder) (err:PhasedDiagnostic) =
742745
os.Append(ParameterlessStructCtorE().Format)|> ignore
743746
| InterfaceNotRevealed(denv,ity,_)->
744747
os.Append(InterfaceNotRevealedE().Format(NicePrint.minimalStringOfType denv ity))|> ignore
745-
| NotAFunction(_,_,hasIndexer,_,marg)->
746-
if hasIndexerthen
747-
os.Append(FSComp.SR.notAFunctionButMaybeIndexer())|> ignore
748-
elif marg.StartColumn=0then
748+
| NotAFunctionButIndexer(_,_,name,_,_)->
749+
match namewith
750+
| Some name-> os.Append(FSComp.SR.notAFunctionButMaybeIndexerWithName name)|> ignore
751+
|_-> os.Append(FSComp.SR.notAFunctionButMaybeIndexer())|> ignore
752+
| NotAFunction(_,_,_,marg)->
753+
if marg.StartColumn=0then
749754
os.Append(FSComp.SR.notAFunctionButMaybeDeclaration())|> ignore
750755
else
751756
os.Append(FSComp.SR.notAFunction())|> ignore
752-
753757
| TyconBadArgs(_,tcref,d,_)->
754758
letexp= tcref.TyparsNoRange.Length
755759
if exp=0then

‎src/fsharp/FSComp.txt‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1412,5 +1412,7 @@ keywordDescriptionUntypedQuotation,"Delimits a untyped code quotation."
14121412
3216,itemNotFoundInTypeDuringDynamicCodeGen,"%s '%s' not found in type '%s' from assembly '%s'. A possible cause may be a version incompatibility. You may need to explicitly reference the correct version of this assembly to allow all referenced components to use the correct version."
14131413
descriptionWordIs,"is"
14141414
notAFunction,"This value is not a function and cannot be applied."
1415-
3217,notAFunctionButMaybeIndexer,"This value is not a function and cannot be applied. Did you intend to call obj.[index] instead of obj[index]?"
1415+
notAFunctionButMaybeIndexerWithName,"This value is not a function and cannot be applied. Did you intend to access the indexer via %s.[index] instead?"
1416+
notAFunctionButMaybeIndexer,"This expression is not a function and cannot be applied. Did you intend to access the indexer via expr.[index] instead?"
1417+
3217,notAFunctionButMaybeIndexerErrorCode,""
14161418
notAFunctionButMaybeDeclaration,"This value is not a function and cannot be applied. Did you forget to terminate a declaration?"

‎src/fsharp/TypeChecker.fs‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ let mkUnitDelayLambda (g: TcGlobals) m e =
7070

7171
exception BakedInMemberConstraintName of string * range
7272
exception FunctionExpected of DisplayEnv * TType * range
73-
exception NotAFunction of DisplayEnv * TType * bool * range * range
73+
exception NotAFunction of DisplayEnv * TType * range * range
74+
exception NotAFunctionButIndexer of DisplayEnv * TType * string option * range * range
7475
exception Recursion of DisplayEnv * Ident * TType * TType * range
7576
exception RecursiveUseCheckedAtRuntime of DisplayEnv * ValRef * range
7677
exception LetRecEvaluatedOutOfOrder of DisplayEnv * ValRef * ValRef * range
@@ -746,7 +747,7 @@ let UnifyFunctionType extraInfo cenv denv mFunExpr ty =
746747
| Some res -> res
747748
| None ->
748749
match extraInfo with
749-
| Some argm -> error (NotAFunction(denv,ty,false,mFunExpr,argm))
750+
| Some argm -> error (NotAFunction(denv,ty,mFunExpr,argm))
750751
| None -> error (FunctionExpected(denv,ty,mFunExpr))
751752

752753
let ReportImplicitlyIgnoredBoolExpression denv m ty expr =
@@ -8222,14 +8223,21 @@ and Propagate cenv overallTy env tpenv (expr: ApplicableExpr) exprty delayed =
82228223
let mArg = arg.Range
82238224
match arg with
82248225
| SynExpr.CompExpr _ -> ()
8225-
| SynExpr.ArrayOrListOfSeqExpr_ ->
8226+
| SynExpr.ArrayOrListOfSeqExpr(_,_,_) ->
82268227
// 'delayed' is about to be dropped on the floor, first do rudimentary checking to get name resolutions in its body
82278228
RecordNameAndTypeResolutions_IdeallyWithoutHavingOtherEffects_Delayed cenv env tpenv delayed
8228-
error (NotAFunction(denv,overallTy,IsIndexerType cenv.g cenv.amap expr.Type,mExpr,mArg))
8229+
if IsIndexerType cenv.g cenv.amap expr.Type then
8230+
match expr.Expr with
8231+
| Expr.Val (d,_,_) ->
8232+
error (NotAFunctionButIndexer(denv,overallTy,Some d.DisplayName,mExpr,mArg))
8233+
| _ ->
8234+
error (NotAFunctionButIndexer(denv,overallTy,None,mExpr,mArg))
8235+
else
8236+
error (NotAFunction(denv,overallTy,mExpr,mArg))
82298237
| _ ->
82308238
// 'delayed' is about to be dropped on the floor, first do rudimentary checking to get name resolutions in its body
82318239
RecordNameAndTypeResolutions_IdeallyWithoutHavingOtherEffects_Delayed cenv env tpenv delayed
8232-
error (NotAFunction(denv,overallTy,false,mExpr,mArg))
8240+
error (NotAFunction(denv,overallTy,mExpr,mArg))
82338241

82348242
propagate delayed expr.Range exprty
82358243

@@ -8315,7 +8323,7 @@ and TcFunctionApplicationThen cenv overallTy env tpenv mExprAndArg expr exprty (
83158323
let bodyOfCompExpr,tpenv = TcComputationOrSequenceExpression cenv env overallTy mFunExpr (Some(expr.Expr,exprty)) tpenv comp
83168324
TcDelayed cenv overallTy env tpenv mExprAndArg (MakeApplicableExprNoFlex cenv bodyOfCompExpr) (tyOfExpr cenv.g bodyOfCompExpr) ExprAtomicFlag.NonAtomic delayed
83178325
| _ ->
8318-
error (NotAFunction(denv,overallTy,false,mFunExpr,mArg))
8326+
error (NotAFunction(denv,overallTy,mFunExpr,mArg))
83198327

83208328
//-------------------------------------------------------------------------
83218329
// TcLongIdentThen : Typecheck "A.B.C<D>.E.F ... " constructs

‎src/fsharp/TypeChecker.fsi‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ val TypeCheckOneSigFile :
6363

6464
exception BakedInMemberConstraintNameofstring*range
6565
exception FunctionExpectedofDisplayEnv*TType*range
66-
exception NotAFunctionofDisplayEnv*TType*bool*range*range
66+
exception NotAFunctionofDisplayEnv*TType*range*range
67+
exception NotAFunctionButIndexerofDisplayEnv*TType*stringoption*range*range
6768
exception RecursionofDisplayEnv*Ast.Ident*TType*TType*range
6869
exception RecursiveUseCheckedAtRuntimeofDisplayEnv*ValRef*range
6970
exception LetRecEvaluatedOutOfOrderofDisplayEnv*ValRef*ValRef*range
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
// #Warnings
2-
//<Expects status="Error" span="(6,9)">This value is not a function and cannot be applied.But the given value has an indexer.Did you intend tocall obj.[index] instead of obj[index]?</Expects>
2+
//<Expects status="Error" span="(6,9)">This value is not a function and cannot be applied. Did you intend toaccess the indexer via d.[index] instead?</Expects>
33
//<Expects status="Error" span="(8,9)" id="FS3217">This value is not a function and cannot be applied.$</Expects>
4+
//<Expects status="Error" span="(12,9)" id="FS3217">This value is not a function and cannot be applied. Did you intend to access the indexer via expr.[index] instead?"</Expects>
45

56
letd=[1,1]|> dict
67
lety= d[1]
78

89
letz= d[|1|]
910

11+
letf()= d
12+
lety=(f())[1]
13+
1014
exit0

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp