'W: Alert unsynchronized access: Stdlib.Sys.interactive

if !sys.interactive then

triggers a warning of

W: Alert unsynchronized access: Stdlib.Sys.interactive The interactive status is a mutable global state,

How do I get rid of this warning ?

1 Like

It’s easy to suppress alerts, as explained here OCaml - Language extensions

But the point of the alert is to make you aware of something that could go wrong with the program and allow you to guard against it.

1 Like
begin[@alert "-unsynchronized_access"]
if not !Sys.interactive then
end

^-- from following above guide

In this case the alert seems silly, Sys.interactive is not made for clients to change, but for the runtime system to setup depending on the context, it should rather have been unit -> bool

Does it trigger by default in OCaml 5 ? If that is the case I think something should be filed upstream to remove the alert. It’s going to be quite annoying. A lot of my programs invoke their main with:

let () = if !Sys.interactive then () else main () 

So that I can load them in the toplevel. I don’t think I want to add all that disabling ceremony to disable this alert in this case.

/cc @octachron @gasche

(I agree that it should be is_interactive : unit -> bool.)

There is something that I don’t understand here. Why is @zeroexcuses seeing the alert, which is disabled by default?

This alert is disabled by default (for the very reason that ti has the potential to be very noisy indeed).

I imagine that there is an -alert +all somewhere in @zeroexcuses setup.

I see thanks. I still think we should remove the alert on that one.

I just tried to create a minimal failure case git repo, and I can’t.

I went back to my original code, removed the

begin[@alert "-unsynchronized_access"]

and it compiles fine without the warning.

As of right now, I can’t replicate the original warning, and I’m not sure what I changed about my guild system.

Sorry for the wild goose chase.

Don’t hesitate to report it if you see the alert again, the alert is really supposed to be experimental and opt-in.

I think I figured it out. In my first msg, I state the warning, but I don’t state where it is from.

In my 2nd msg, I claim I can no longer reproduce the warning. (I was trying via dune build).

Well, it turns out: I can produce the warning in neovim/merlin as follows. (This does not produce a warning via dune build either). I think this is what I was looking at in my first msg when I reported the warning. Full data below:

  (name m_gen)
  (public_name m_gen)
  (preprocess (pps ppx_jane lwt_ppx ppx_let))
  (libraries 
    compiler-libs.common))
===

if not !Sys.interactive then
  ()
  ;;

In emacs+merlin, Sys.interactive is colored in red and reported as an error.
This must be quite recent, I’m sure this was not the case a while ago

I think that’s due to The "unstable" alert in OCaml 5.0 is enabled by default in merlin · Issue #1558 · ocaml/merlin · GitHub.

1 Like

Can confirm I’m on OCaml 5

This is indeed the root cause, that should be fixed with the next release of Merlin.