Skip to content

Commit 6552688

Browse files
Fix - 16118 : Regression: Cannot use two or more open sessions in FCS 43.7.200+ (#16140)
Co-authored-by: Kevin Ransom <[email protected]>
1 parent ffef561 commit 6552688

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

src/Compiler/Checking/CheckDeclarations.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ let BuildRootModuleContents (isModule: bool) enclosingNamespacePath (cpath: Comp
260260
||> List.foldBack (fun id (cpath, moduleContents) -> (cpath.ParentCompPath, wrapModuleOrNamespaceContentsInNamespace isModule id cpath.ParentCompPath moduleContents))
261261
|> snd
262262

263-
/// Try to take the "FSINNN" prefix off a namespace path
263+
/// Try to take the "FSI_NNN" prefix off a namespace path
264264
let TryStripPrefixPath (g: TcGlobals) (enclosingNamespacePath: Ident list) =
265265
match enclosingNamespacePath with
266266
| p :: rest when

src/Compiler/Interactive/fsi.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,7 +1837,7 @@ type internal FsiDynamicCompiler
18371837
let opts =
18381838
{
18391839
ilg = tcGlobals.ilg
1840-
outfile = multiAssemblyName + ".dll"
1840+
outfile = $"{multiAssemblyName}-{dynamicAssemblyId}.dll"
18411841
pdbfile = Some(Path.Combine(scriptingSymbolsPath.Value, $"{multiAssemblyName}-{dynamicAssemblyId}.pdb"))
18421842
emitTailcalls = tcConfig.emitTailcalls
18431843
deterministic = tcConfig.deterministic
@@ -3306,8 +3306,8 @@ type internal MagicAssemblyResolution() =
33063306
| None ->
33073307
// Check dynamic assemblies by simple name
33083308
match fsiDynamicCompiler.FindDynamicAssembly(simpleAssemName, false) with
3309-
| Some asm -> asm
3310-
| None ->
3309+
| Some asm when not (tcConfigB.fsiMultiAssemblyEmit) -> asm
3310+
| _ ->
33113311

33123312
// Otherwise continue
33133313
let assemblyReferenceTextDll = (simpleAssemName + ".dll")

tests/FSharp.Compiler.ComponentTests/Scripting/Interactive.fs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ namespace Scripting
55
open Xunit
66
open System
77
open FSharp.Test.Compiler
8+
open FSharp.Compiler.Interactive.Shell
9+
open FSharp.Test.ScriptHelpers
810

911
module ``Interactive tests`` =
12+
1013
[<Fact>]
1114
let ``Eval object value``() =
1215
Fsx "1+1"
@@ -31,6 +34,35 @@ module ``Interactive tests`` =
3134
(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.")
3235
]
3336

37+
[<Theory>]
38+
[<InlineData(true)>]
39+
[<InlineData(false)>]
40+
let ``Evaluation of multiple sessions should succeed`` (useMultiEmit) =
41+
42+
let args : string array = [| if useMultiEmit then "--multiemit+" else "--multiemit-"|]
43+
use sessionOne = new FSharpScript(additionalArgs=args)
44+
use sessionTwo = new FSharpScript(additionalArgs=args)
45+
46+
sessionOne.Eval("""
47+
module Test1 =
48+
49+
let test1 obj = sprintf "Execute - Test1.test1 - %A" obj""") |> ignore
50+
51+
let result1 = sessionOne.Eval("""Test1.test1 18""") |> getValue
52+
let value1 = result1.Value
53+
Assert.Equal(typeof<string>, value1.ReflectionType)
54+
Assert.Equal("Execute - Test1.test1 - 18", value1.ReflectionValue :?> string)
55+
56+
sessionTwo.Eval("""
57+
module Test2 =
58+
59+
let test2 obj = sprintf "Execute - Test2.test2 - %A" obj""") |> ignore
60+
61+
let result2 = sessionTwo.Eval("""Test2.test2 27""") |> getValue
62+
let value2 = result2.Value
63+
Assert.Equal(typeof<string>, value2.ReflectionType)
64+
Assert.Equal("Execute - Test2.test2 - 27", value2.ReflectionValue :?> string)
65+
3466
module ``External FSI tests`` =
3567
[<Fact>]
3668
let ``Eval object value``() =

0 commit comments

Comments
 (0)