提交 5acc1009 编写于 作者: S Steffen Forkmann

Better wording

上级 6abbbf57
......@@ -203,7 +203,10 @@ let GetRangeOfDiagnostic(err:PhasedDiagnostic) =
| SelfRefObjCtor(_,m) ->
Some m
| NotAFunction(_,_,_,mfun,_) ->
| NotAFunction(_,_,mfun,_) ->
Some mfun
| NotAFunctionButIndexer(_,_,_,mfun,_) ->
Some mfun
| IllegalFileNameChar(_) -> Some rangeCmdArgs
......@@ -243,7 +246,7 @@ let GetDiagnosticNumber(err:PhasedDiagnostic) =
(* DO NOT CHANGE THESE NUMBERS *)
| ErrorFromAddingTypeEquation _ -> 1
| FunctionExpected _ -> 2
| NotAFunction (_,_,true,_,_) -> 3217
| NotAFunctionButIndexer _ -> 3217
| NotAFunction _ -> 3
| FieldNotMutable _ -> 5
| Recursion _ -> 6
......@@ -742,14 +745,15 @@ let OutputPhasedErrorR (os:StringBuilder) (err:PhasedDiagnostic) =
os.Append(ParameterlessStructCtorE().Format) |> ignore
| InterfaceNotRevealed(denv,ity,_) ->
os.Append(InterfaceNotRevealedE().Format (NicePrint.minimalStringOfType denv ity)) |> ignore
| NotAFunction(_,_,hasIndexer,_,marg) ->
if hasIndexer then
os.Append(FSComp.SR.notAFunctionButMaybeIndexer()) |> ignore
elif marg.StartColumn = 0 then
| NotAFunctionButIndexer(_,_,name,_,_) ->
match name with
| Some name -> os.Append(FSComp.SR.notAFunctionButMaybeIndexerWithName name) |> ignore
| _ -> os.Append(FSComp.SR.notAFunctionButMaybeIndexer()) |> ignore
| NotAFunction(_,_,_,marg) ->
if marg.StartColumn = 0 then
os.Append(FSComp.SR.notAFunctionButMaybeDeclaration()) |> ignore
else
os.Append(FSComp.SR.notAFunction()) |> ignore
| TyconBadArgs(_,tcref,d,_) ->
let exp = tcref.TyparsNoRange.Length
if exp = 0 then
......
......@@ -1412,5 +1412,7 @@ keywordDescriptionUntypedQuotation,"Delimits a untyped code quotation."
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."
descriptionWordIs,"is"
notAFunction,"This value is not a function and cannot be applied."
3217,notAFunctionButMaybeIndexer,"This value is not a function and cannot be applied. Did you intend to call obj.[index] instead of obj[index]?"
notAFunctionButMaybeIndexerWithName,"This value is not a function and cannot be applied. Did you intend to access the indexer via %s.[index] instead?"
notAFunctionButMaybeIndexer,"This expression is not a function and cannot be applied. Did you intend to access the indexer via expr.[index] instead?"
3217,notAFunctionButMaybeIndexerErrorCode,""
notAFunctionButMaybeDeclaration,"This value is not a function and cannot be applied. Did you forget to terminate a declaration?"
......@@ -70,7 +70,8 @@ let mkUnitDelayLambda (g: TcGlobals) m e =
exception BakedInMemberConstraintName of string * range
exception FunctionExpected of DisplayEnv * TType * range
exception NotAFunction of DisplayEnv * TType * bool * range * range
exception NotAFunction of DisplayEnv * TType * range * range
exception NotAFunctionButIndexer of DisplayEnv * TType * string option * range * range
exception Recursion of DisplayEnv * Ident * TType * TType * range
exception RecursiveUseCheckedAtRuntime of DisplayEnv * ValRef * range
exception LetRecEvaluatedOutOfOrder of DisplayEnv * ValRef * ValRef * range
......@@ -746,7 +747,7 @@ let UnifyFunctionType extraInfo cenv denv mFunExpr ty =
| Some res -> res
| None ->
match extraInfo with
| Some argm -> error (NotAFunction(denv,ty,false,mFunExpr,argm))
| Some argm -> error (NotAFunction(denv,ty,mFunExpr,argm))
| None -> error (FunctionExpected(denv,ty,mFunExpr))
let ReportImplicitlyIgnoredBoolExpression denv m ty expr =
......@@ -8222,14 +8223,21 @@ and Propagate cenv overallTy env tpenv (expr: ApplicableExpr) exprty delayed =
let mArg = arg.Range
match arg with
| SynExpr.CompExpr _ -> ()
| SynExpr.ArrayOrListOfSeqExpr _ ->
| SynExpr.ArrayOrListOfSeqExpr (_,_,_) ->
// 'delayed' is about to be dropped on the floor, first do rudimentary checking to get name resolutions in its body
RecordNameAndTypeResolutions_IdeallyWithoutHavingOtherEffects_Delayed cenv env tpenv delayed
error (NotAFunction(denv,overallTy,IsIndexerType cenv.g cenv.amap expr.Type,mExpr,mArg))
if IsIndexerType cenv.g cenv.amap expr.Type then
match expr.Expr with
| Expr.Val (d,_,_) ->
error (NotAFunctionButIndexer(denv,overallTy,Some d.DisplayName,mExpr,mArg))
| _ ->
error (NotAFunctionButIndexer(denv,overallTy,None,mExpr,mArg))
else
error (NotAFunction(denv,overallTy,mExpr,mArg))
| _ ->
// 'delayed' is about to be dropped on the floor, first do rudimentary checking to get name resolutions in its body
RecordNameAndTypeResolutions_IdeallyWithoutHavingOtherEffects_Delayed cenv env tpenv delayed
error (NotAFunction(denv,overallTy,false,mExpr,mArg))
error (NotAFunction(denv,overallTy,mExpr,mArg))
propagate delayed expr.Range exprty
......@@ -8315,7 +8323,7 @@ and TcFunctionApplicationThen cenv overallTy env tpenv mExprAndArg expr exprty (
let bodyOfCompExpr,tpenv = TcComputationOrSequenceExpression cenv env overallTy mFunExpr (Some(expr.Expr,exprty)) tpenv comp
TcDelayed cenv overallTy env tpenv mExprAndArg (MakeApplicableExprNoFlex cenv bodyOfCompExpr) (tyOfExpr cenv.g bodyOfCompExpr) ExprAtomicFlag.NonAtomic delayed
| _ ->
error (NotAFunction(denv,overallTy,false,mFunExpr,mArg))
error (NotAFunction(denv,overallTy,mFunExpr,mArg))
//-------------------------------------------------------------------------
// TcLongIdentThen : Typecheck "A.B.C<D>.E.F ... " constructs
......
......@@ -63,7 +63,8 @@ val TypeCheckOneSigFile :
exception BakedInMemberConstraintName of string * range
exception FunctionExpected of DisplayEnv * TType * range
exception NotAFunction of DisplayEnv * TType * bool * range * range
exception NotAFunction of DisplayEnv * TType * range * range
exception NotAFunctionButIndexer of DisplayEnv * TType * string option * range * range
exception Recursion of DisplayEnv * Ast.Ident * TType * TType * range
exception RecursiveUseCheckedAtRuntime of DisplayEnv * ValRef * range
exception LetRecEvaluatedOutOfOrder of DisplayEnv * ValRef * ValRef * range
......
// #Warnings
//<Expects status="Error" span="(6,9)" id="FS3217">This value is not a function and cannot be applied. But the given value has an indexer. Did you intend to call obj.[index] instead of obj[index]?</Expects>
//<Expects status="Error" span="(6,9)" id="FS3217">This value is not a function and cannot be applied. Did you intend to access the indexer via d.[index] instead?</Expects>
//<Expects status="Error" span="(8,9)" id="FS3217">This value is not a function and cannot be applied.$</Expects>
//<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>
let d = [1,1] |> dict
let y = d[1]
let z = d[|1|]
let f() = d
let y = (f())[1]
exit 0
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册