-
Notifications
You must be signed in to change notification settings - Fork 847
Description
Issue Description:
Trying to go through Tutorial: Hosted Execution from fsharp.github.io (https://fsharp.github.io/fsharp-compiler-docs/fcs/interactive.html).
Basically trying to start a FsiEvaluationSession and evaluate f# code.
Steps required to reproduce the problem:
- Start Repl (either Visual Studio 2022's repl or dotnet fsi has the same outcome)
- Send tutorial code snippets to fsi
- When the following line is evaluated,
evalExpression "42 + 1"
FsiEvaluationSession throws an exception:
> evalExpression "42 + 1";;
FSharp.Compiler.Interactive.Shell+FsiCompilationException: Operation failed. The error text has been printed in the error stream. To return the corresponding FSharpDiagnostic use the EvalInteractionNonThrowing, EvalScriptNonThrowing or EvalExpressionNonThrowing
at FSharp.Compiler.Interactive.Shell.FsiEvaluationSession.commitResult[a,b](FSharpChoice`2 res) in D:\a_work\1\s\src\Compiler\Interactive\fsi.fs:line 3418
at FSI_0032.evalExpression(String text)
at <StartupCode$FSI_0033>.$FSI_0033.main@()
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
Stopped due to error
when looking at error stream I find the following output:
_> printf "%A" errStream;;
error FS0193: internal error: The thread is already executing the ControlledExecution.Run method._
Expected behavior
Of course the expectation is that FSIEvaluationSession wouldn't throw exception when tutorial is performed
in FSI (Assumption based on the fact that fsi #r directive is used in tutorial code samples).
Otherwise (hopefully not), please add note in the tutorial itself stating fsi is not a supported environment for FsiEvaluationSession.
Actual behavior
when evaluating a code snipet via any FsiEvaluationExpression eval methods, the following exception ends its execution:
error FS0193: internal error: The thread is already executing the ControlledExecution.Run method.
Known workarounds
Compiling the tutorial code samples as F# Console App works fine!
Couldn't find any workaround for successful execution in FSI.
Related information
Using the following reference of F# Compiler Services:
#r "nuget: FSharp.Compiler.Service, 42.7.101"
- Operating system
Windows 11 - .NET Runtime kind (.NET Core, .NET Framework, Mono)
- fsi;;
val it: FSharp.Compiler.Interactive.InteractiveSession =
FSharp.Compiler.Interactive.InteractiveSession
{CommandLineArgs = [|"C:\Program Files\dotnet\sdk\7.0.102\FSharp\fsi.dll"|]; - Editing Tools (e.g. Visual Studio Version, Visual Studio)
Same behavior from both VS F# Interactive window and dotnet fsi
Metadata
Metadata
Assignees
Labels
Type
Projects
Status