Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/dev17.8] Fix - 16118 : Regression: Cannot use two or more open sessions in FCS… #16140

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Compiler/Checking/CheckDeclarations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ let BuildRootModuleContents (isModule: bool) enclosingNamespacePath (cpath: Comp
||> List.foldBack (fun id (cpath, moduleContents) -> (cpath.ParentCompPath, wrapModuleOrNamespaceContentsInNamespace isModule id cpath.ParentCompPath moduleContents))
|> snd

/// Try to take the "FSINNN" prefix off a namespace path
/// Try to take the "FSI_NNN" prefix off a namespace path
let TryStripPrefixPath (g: TcGlobals) (enclosingNamespacePath: Ident list) =
match enclosingNamespacePath with
| p :: rest when
Expand Down
6 changes: 3 additions & 3 deletions src/Compiler/Interactive/fsi.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1837,7 +1837,7 @@ type internal FsiDynamicCompiler
let opts =
{
ilg = tcGlobals.ilg
outfile = multiAssemblyName + ".dll"
outfile = $"{multiAssemblyName}-{dynamicAssemblyId}.dll"
pdbfile = Some(Path.Combine(scriptingSymbolsPath.Value, $"{multiAssemblyName}-{dynamicAssemblyId}.pdb"))
emitTailcalls = tcConfig.emitTailcalls
deterministic = tcConfig.deterministic
Expand Down Expand Up @@ -3306,8 +3306,8 @@ type internal MagicAssemblyResolution() =
| None ->
// Check dynamic assemblies by simple name
match fsiDynamicCompiler.FindDynamicAssembly(simpleAssemName, false) with
| Some asm -> asm
| None ->
| Some asm when not (tcConfigB.fsiMultiAssemblyEmit) -> asm
| _ ->

// Otherwise continue
let assemblyReferenceTextDll = (simpleAssemName + ".dll")
Expand Down
32 changes: 32 additions & 0 deletions tests/FSharp.Compiler.ComponentTests/Scripting/Interactive.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ namespace Scripting
open Xunit
open System
open FSharp.Test.Compiler
open FSharp.Compiler.Interactive.Shell
open FSharp.Test.ScriptHelpers

module ``Interactive tests`` =

[<Fact>]
let ``Eval object value``() =
Fsx "1+1"
Expand All @@ -31,6 +34,35 @@ module ``Interactive tests`` =
(Warning 2304, Line 1, Col 3, Line 1, Col 13, "Functions with [<EntryPoint>] are not invoked in FSI. 'myFunc' was not invoked. Execute 'myFunc <args>' in order to invoke 'myFunc' with the appropriate string array of command line arguments.")
]

[<Theory>]
[<InlineData(true)>]
[<InlineData(false)>]
let ``Evaluation of multiple sessions should succeed`` (useMultiEmit) =

let args : string array = [| if useMultiEmit then "--multiemit+" else "--multiemit-"|]
use sessionOne = new FSharpScript(additionalArgs=args)
use sessionTwo = new FSharpScript(additionalArgs=args)

sessionOne.Eval("""
module Test1 =

let test1 obj = sprintf "Execute - Test1.test1 - %A" obj""") |> ignore

let result1 = sessionOne.Eval("""Test1.test1 18""") |> getValue
let value1 = result1.Value
Assert.Equal(typeof<string>, value1.ReflectionType)
Assert.Equal("Execute - Test1.test1 - 18", value1.ReflectionValue :?> string)

sessionTwo.Eval("""
module Test2 =

let test2 obj = sprintf "Execute - Test2.test2 - %A" obj""") |> ignore

let result2 = sessionTwo.Eval("""Test2.test2 27""") |> getValue
let value2 = result2.Value
Assert.Equal(typeof<string>, value2.ReflectionType)
Assert.Equal("Execute - Test2.test2 - 27", value2.ReflectionValue :?> string)

module ``External FSI tests`` =
[<Fact>]
let ``Eval object value``() =
Expand Down