Skip to content

Commit 1c232b5

Browse files
KevinRansombaronfel
authored andcommitted
Warn on invalided FSI directives. (#9601)
* cleanup fsi a bit * Update baselines
1 parent f4083d1 commit 1c232b5

4 files changed

Lines changed: 37 additions & 36 deletions

File tree

clean.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ DEAD_DIRS=(
1212
"src/fsharp/FSharp.Build"
1313
"src/fsharp/FSharp.Compiler.nuget/Microsoft.FSharp.Compiler.nuspec"
1414
"src/fsharp/FSharp.Compiler.Private/FSharp.Compiler.Private.fsproj"
15+
"src/fsharp/fsi/xlf"
1516
"src/fsharp/fsi/fsi.fsproj"
1617
"src/fsharp/fsiAnyCpu/fsiAnyCpu.fsproj"
1718
"src/fsharp/Interactive.DependencyManager/xlf"

src/fsharp/FSComp.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1512,7 +1512,8 @@ featureFixedIndexSlice3d4d,"fixed-index slice 3d/4d"
15121512
featureAndBang,"applicative computation expressions"
15131513
featureNullableOptionalInterop,"nullable optional interop"
15141514
featureDefaultInterfaceMemberConsumption,"default interface member consumption"
1515-
featureWitnessPassing,"witness passing"
15161515
3360,typrelInterfaceWithConcreteAndVariable,"'%s' cannot implement the interface '%s' with the two instantiations '%s' and '%s' because they may unify."
15171516
3361,typrelInterfaceWithConcreteAndVariableObjectExpression,"You cannot implement the interface '%s' with the two instantiations '%s' and '%s' because they may unify."
15181517
featureInterfacesWithMultipleGenericInstantiation,"interfaces with multiple generic instantiation"
1518+
featureWitnessPassing,"witness passing for trait constraints in F# quotations"
1519+
3353,fsiInvalidDirective,"Invalid directive '#%s %s'"

src/fsharp/fsi/FSIstrings.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ fsiBanner3,"For help type #help;;"
2121
fsiConsoleProblem,"A problem occurred starting the F# Interactive process. This may be due to a known problem with background process console support for Unicode-enabled applications on some Windows systems. Try selecting Tools->Options->F# Interactive for Visual Studio and enter '--fsi-server-no-unicode'."
2222
2301,fsiInvalidAssembly,"'%s' is not a valid assembly name"
2323
2302,fsiDirectoryDoesNotExist,"Directory '%s' doesn't exist"
24-
fsiInvalidDirective,"Invalid directive '#%s %s'"
2524
fsiLineTooLong,"Warning: line too long, ignoring some characters\n"
2625
fsiTimeInfoMainString,"Real: %s, CPU: %s, GC %s"
2726
fsiTimeInfoGCGenerationLabelSomeShorthandForTheWordGeneration,"gen"

src/fsharp/fsi/fsi.fs

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,7 +2053,7 @@ type internal FsiInteractionProcessor
20532053
f istate
20542054
with e ->
20552055
stopProcessingRecovery e range0
2056-
istate,CompletedWithReportedError e
2056+
istate, CompletedWithReportedError e
20572057

20582058
let isFeatureSupported featureId = tcConfigB.langVersion.SupportsFeature featureId
20592059

@@ -2099,19 +2099,19 @@ type internal FsiInteractionProcessor
20992099
let ExecInteraction (ctok, tcConfig:TcConfig, istate, action:ParsedFsiInteraction, errorLogger: ErrorLogger) =
21002100
istate |> InteractiveCatch errorLogger (fun istate ->
21012101
match action with
2102-
| IDefns ([ ],_) ->
2102+
| IDefns ([], _) ->
21032103
let istate = fsiDynamicCompiler.CommitDependencyManagerText(ctok, istate, lexResourceManager, errorLogger)
21042104
istate,Completed None
21052105

2106-
| IDefns ([ SynModuleDecl.DoExpr(_,expr,_)],_) ->
2106+
| IDefns ([SynModuleDecl.DoExpr(_, expr, _)], _) ->
21072107
let istate = fsiDynamicCompiler.CommitDependencyManagerText(ctok, istate, lexResourceManager, errorLogger)
21082108
fsiDynamicCompiler.EvalParsedExpression(ctok, errorLogger, istate, expr)
21092109

21102110
| IDefns (defs,_) ->
21112111
let istate = fsiDynamicCompiler.CommitDependencyManagerText(ctok, istate, lexResourceManager, errorLogger)
21122112
fsiDynamicCompiler.EvalParsedDefinitions (ctok, errorLogger, istate, true, false, defs)
21132113

2114-
| IHash (ParsedHashDirective("load",sourceFiles,m),_) ->
2114+
| IHash (ParsedHashDirective("load", sourceFiles, m), _) ->
21152115
let istate = fsiDynamicCompiler.CommitDependencyManagerText(ctok, istate, lexResourceManager, errorLogger)
21162116
fsiDynamicCompiler.EvalSourceFiles (ctok, istate, m, sourceFiles, lexResourceManager, errorLogger),Completed None
21172117

@@ -2161,69 +2161,69 @@ type internal FsiInteractionProcessor
21612161
fsiConsoleOutput.uprintnfnn "%s" format)
21622162
istate,Completed None
21632163

2164-
| IHash (ParsedHashDirective("I",[path],m),_) ->
2165-
tcConfigB.AddIncludePath (m,path, tcConfig.implicitIncludeDir)
2164+
| IHash (ParsedHashDirective("I", [path], m), _) ->
2165+
tcConfigB.AddIncludePath (m, path, tcConfig.implicitIncludeDir)
21662166
fsiConsoleOutput.uprintnfnn "%s" (FSIstrings.SR.fsiDidAHashI(tcConfig.MakePathAbsolute path))
2167-
istate,Completed None
2167+
istate, Completed None
21682168

2169-
| IHash (ParsedHashDirective("cd",[path],m),_) ->
2169+
| IHash (ParsedHashDirective("cd", [path], m), _) ->
21702170
ChangeDirectory path m
2171-
istate,Completed None
2171+
istate, Completed None
21722172

2173-
| IHash (ParsedHashDirective("silentCd",[path],m),_) ->
2173+
| IHash (ParsedHashDirective("silentCd", [path], m), _) ->
21742174
ChangeDirectory path m
21752175
fsiConsolePrompt.SkipNext() (* "silent" directive *)
2176-
istate,Completed None
2176+
istate, Completed None
21772177

2178-
| IHash (ParsedHashDirective("dbgbreak",[],_),_) ->
2179-
{istate with debugBreak = true},Completed None
2178+
| IHash (ParsedHashDirective("dbgbreak", [], _), _) ->
2179+
{istate with debugBreak = true}, Completed None
21802180

2181-
| IHash (ParsedHashDirective("time",[],_),_) ->
2181+
| IHash (ParsedHashDirective("time", [], _), _) ->
21822182
if istate.timing then
21832183
fsiConsoleOutput.uprintnfnn "%s" (FSIstrings.SR.fsiTurnedTimingOff())
21842184
else
21852185
fsiConsoleOutput.uprintnfnn "%s" (FSIstrings.SR.fsiTurnedTimingOn())
2186-
{istate with timing = not istate.timing},Completed None
2186+
{istate with timing = not istate.timing}, Completed None
21872187

2188-
| IHash (ParsedHashDirective("time",[("on" | "off") as v],_),_) ->
2188+
| IHash (ParsedHashDirective("time", [("on" | "off") as v], _), _) ->
21892189
if v <> "on" then
21902190
fsiConsoleOutput.uprintnfnn "%s" (FSIstrings.SR.fsiTurnedTimingOff())
21912191
else
21922192
fsiConsoleOutput.uprintnfnn "%s" (FSIstrings.SR.fsiTurnedTimingOn())
2193-
{istate with timing = (v = "on")},Completed None
2193+
{istate with timing = (v = "on")}, Completed None
21942194

2195-
| IHash (ParsedHashDirective("nowarn",numbers,m),_) ->
2196-
List.iter (fun (d:string) -> tcConfigB.TurnWarningOff(m,d)) numbers
2197-
istate,Completed None
2195+
| IHash (ParsedHashDirective("nowarn", numbers, m), _) ->
2196+
List.iter (fun (d:string) -> tcConfigB.TurnWarningOff(m, d)) numbers
2197+
istate, Completed None
21982198

2199-
| IHash (ParsedHashDirective("terms",[],_),_) ->
2199+
| IHash (ParsedHashDirective("terms", [], _), _) ->
22002200
tcConfigB.showTerms <- not tcConfig.showTerms
2201-
istate,Completed None
2201+
istate, Completed None
22022202

2203-
| IHash (ParsedHashDirective("types",[],_),_) ->
2203+
| IHash (ParsedHashDirective("types", [], _), _) ->
22042204
fsiOptions.ShowTypes <- not fsiOptions.ShowTypes
2205-
istate,Completed None
2205+
istate, Completed None
22062206

22072207
#if DEBUG
2208-
| IHash (ParsedHashDirective("ilcode",[],_m),_) ->
2208+
| IHash (ParsedHashDirective("ilcode", [], _m), _) ->
22092209
fsiOptions.ShowILCode <- not fsiOptions.ShowILCode;
2210-
istate,Completed None
2210+
istate, Completed None
22112211

2212-
| IHash (ParsedHashDirective("info",[],_m),_) ->
2212+
| IHash (ParsedHashDirective("info", [], _m), _) ->
22132213
PrintOptionInfo tcConfigB
2214-
istate,Completed None
2214+
istate, Completed None
22152215
#endif
22162216

2217-
| IHash (ParsedHashDirective(("q" | "quit"),[],_),_) ->
2217+
| IHash (ParsedHashDirective(("q" | "quit"), [], _), _) ->
22182218
fsiInterruptController.Exit()
22192219

2220-
| IHash (ParsedHashDirective("help",[],_),_) ->
2220+
| IHash (ParsedHashDirective("help", [], _), _) ->
22212221
fsiOptions.ShowHelp()
2222-
istate,Completed None
2222+
istate, Completed None
22232223

2224-
| IHash (ParsedHashDirective(c,arg,_),_) ->
2225-
fsiConsoleOutput.uprintfn "%s" (FSIstrings.SR.fsiInvalidDirective(c, String.concat " " arg)) // REVIEW: uprintnfnn - like other directives above
2226-
istate,Completed None (* REVIEW: cont = CompletedWithReportedError *)
2224+
| IHash (ParsedHashDirective(c, arg, m), _) ->
2225+
warning(Error((FSComp.SR.fsiInvalidDirective(c, String.concat " " arg)), m))
2226+
istate, Completed None
22272227
)
22282228

22292229
/// Execute a single parsed interaction which may contain multiple items to be executed

0 commit comments

Comments
 (0)