The compiler's values of a compilation are written as .Value

The compiler keeps the state of a compilation in a context
(Compilation.fs, on its branch compilation-context), and a value that was a
module-level mutable is a Per. The server sets Diagnostics.verbose,
Paths.sourceOverrides, Paths.compilerAssembly and the five observers, each
now as x.Value <- ...

No change to what the server does: every check still runs in the one root
context.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Linus Björnstam 2026-11-25 08:39:42 +01:00
parent ce426b94df
commit c5acafd5dd
5 changed files with 14 additions and 14 deletions

View file

@ -232,9 +232,9 @@ let private options: Build.Options = { Build.dependencyOptions with IsLibrary =
/// check failed with nothing collected: a failure the compiler printed rather /// check failed with nothing collected: a failure the compiler printed rather
/// than recorded, such as a bug in it, which would otherwise fail silently. /// than recorded, such as a bug in it, which would otherwise fail silently.
let file (buffers: Map<string, string>) (path: string) : Found list = let file (buffers: Map<string, string>) (path: string) : Found list =
Diagnostics.verbose <- false Diagnostics.verbose.Value <- false
Diagnostics.reset () Diagnostics.reset ()
Paths.sourceOverrides <- buffers Paths.sourceOverrides.Value <- buffers
// The text the check reads, for what to mark at a column and for where // The text the check reads, for what to mark at a column and for where
// the types it infers are. // the types it infers are.
@ -256,7 +256,7 @@ let file (buffers: Map<string, string>) (path: string) : Found list =
printfn "%s" (Diagnostics.humanize ex.Message) printfn "%s" (Diagnostics.humanize ex.Message)
1) 1)
finally finally
Paths.sourceOverrides <- Map.empty Paths.sourceOverrides.Value <- Map.empty
// With BJOLANG_TIMING set, where the check's time went, to the log. // With BJOLANG_TIMING set, where the check's time went, to the log.
if Timing.enabled then if Timing.enabled then

View file

@ -143,7 +143,7 @@ let private renamed = Collections.Generic.Dictionary<string, string>()
let recording (path: string) (check: unit -> 'a) : 'a = let recording (path: string) (check: unit -> 'a) : 'a =
let seen = ResizeArray<Record>() let seen = ResizeArray<Record>()
Macro.observe <- Macro.observe.Value <-
Some(fun macro site input output names -> Some(fun macro site input output names ->
for KeyValue(fresh, original) in names do for KeyValue(fresh, original) in names do
renamed[fresh] <- original renamed[fresh] <- original
@ -157,7 +157,7 @@ let recording (path: string) (check: unit -> 'a) : 'a =
try try
check () check ()
finally finally
Macro.observe <- None Macro.observe.Value <- None
let full = IO.Path.GetFullPath path let full = IO.Path.GetFullPath path
// A form can be expanded more than once in one check, as a // A form can be expanded more than once in one check, as a

View file

@ -28,16 +28,16 @@ let recording (path: string) (check: unit -> 'a) : 'a =
let missing = ResizeArray<Exhaustiveness.MissingClauses>() let missing = ResizeArray<Exhaustiveness.MissingClauses>()
let holes = ResizeArray<Holes.Fillers>() let holes = ResizeArray<Holes.Fillers>()
let signatures = ResizeArray<CheckDecl.MissingSignature>() let signatures = ResizeArray<CheckDecl.MissingSignature>()
Exhaustiveness.observe <- Some(fun m -> if inFile m.Range then missing.Add m) Exhaustiveness.observe.Value <- Some(fun m -> if inFile m.Range then missing.Add m)
Holes.observe <- Some(fun h -> if inFile h.Range then holes.Add h) Holes.observe.Value <- Some(fun h -> if inFile h.Range then holes.Add h)
CheckDecl.observeMissingSignature <- Some(fun s -> if inFile s.Range then signatures.Add s) CheckDecl.observeMissingSignature.Value <- Some(fun s -> if inFile s.Range then signatures.Add s)
try try
check () check ()
finally finally
Exhaustiveness.observe <- None Exhaustiveness.observe.Value <- None
Holes.observe <- None Holes.observe.Value <- None
CheckDecl.observeMissingSignature <- None CheckDecl.observeMissingSignature.Value <- None
byFile[full] <- byFile[full] <-
{ Missing = missing |> Seq.distinctBy (fun m -> m.Range) |> List.ofSeq { Missing = missing |> Seq.distinctBy (fun m -> m.Range) |> List.ofSeq

View file

@ -30,7 +30,7 @@ let private useInstalledCompiler () =
let installed = IO.Path.Combine(Bjolang.Paths.root, "bin", "compiler", "Bjolang.dll") let installed = IO.Path.Combine(Bjolang.Paths.root, "bin", "compiler", "Bjolang.dll")
if IO.File.Exists installed then if IO.File.Exists installed then
Bjolang.Paths.compilerAssembly <- installed Bjolang.Paths.compilerAssembly.Value <- installed
Environment.SetEnvironmentVariable("BJOLANG_OUT_OF_PROCESS_DEPS", "1") Environment.SetEnvironmentVariable("BJOLANG_OUT_OF_PROCESS_DEPS", "1")
Bjolang.Build.installDependencyBackend () Bjolang.Build.installDependencyBackend ()
Environment.SetEnvironmentVariable("BJOLANG_OUT_OF_PROCESS_DEPS", null) Environment.SetEnvironmentVariable("BJOLANG_OUT_OF_PROCESS_DEPS", null)

View file

@ -194,7 +194,7 @@ let recording (path: string) (text: string) (check: unit -> 'a) : 'a =
let full = IO.Path.GetFullPath path let full = IO.Path.GetFullPath path
let mutable index = empty let mutable index = empty
Inference.observe <- Inference.observe.Value <-
Some(fun env decls -> Some(fun env decls ->
// The first program with names in the file is the file's: one // The first program with names in the file is the file's: one
// checked before it is a dependency's. // checked before it is a dependency's.
@ -204,7 +204,7 @@ let recording (path: string) (text: string) (check: unit -> 'a) : 'a =
try try
check () check ()
finally finally
Inference.observe <- None Inference.observe.Value <- None
byFile[full] <- index byFile[full] <- index
checkedTexts[full] <- text checkedTexts[full] <- text