Giter Club home page Giter Club logo

Comments (11)

purcell avatar purcell commented on June 9, 2024 1

This is likely the same issue that intero had to work around: if you load the same file twice in ghci, and it has warnings but not errors, ghci does not report the the warnings the second time it is loaded.

from dante.

zarybnicky avatar zarybnicky commented on June 9, 2024

Ok, I take it back - that change just made it so that the warnings don't disappear if I save the file immediately after some changes, which they did before... So I'm back to 'no idea where the problem is'. I guess I can work around it by not saving the file immediately after some changes, which I do by reflex now after some unpleasant experiences with crashing APL environments.

from dante.

zarybnicky avatar zarybnicky commented on June 9, 2024

from dante.

purcell avatar purcell commented on June 9, 2024

@zarybnicky We subsequently changed the code for that, so be sure to check out how it works in the latest intero. It's unfortunate that it adds some complexity.

from dante.

jyp avatar jyp commented on June 9, 2024

As often, I would recommend bringing this issue to the attention of the GHCi maintainers.
Furthermore, the speed of the checker would be impacted by doing anything else than a simple reload. (And in general I hate increasing the complexity just to work around upstream issues.)

from dante.

chrisdone avatar chrisdone commented on June 9, 2024

The reliable fix is here: chrisdone-archive/intero#468

GHCi doesn't report warnings because you changed the file too rapidly, below <1 second duration. So in reporting whatever the last warnings were, if your users make a change too rapidly, then it'll report warnings for old code. I had this situation in Intero. The change in 62c3057 will report incorrect warnings sometimes.

from dante.

jyp avatar jyp commented on June 9, 2024

@chrisdone This does not seem to happen with my setup. What is the sequence of steps to reproduce the bug?

from dante.

chrisdone avatar chrisdone commented on June 9, 2024

It's GHCi behavior:

bash-3.2$ cat > input.txt
:set -Wall -fobject-code
:!echo "x = 'a'" > x.hs
:l x.hs
:!echo "y = 'a'" > x.hs
:l x.hs
:q
bash-3.2$ cat input.txt | ghci
GHCi, version 8.0.1: http://www.haskell.org/ghc/  :? for help
Prelude> Prelude> Prelude> [1 of 1] Compiling Main             ( x.hs, x.o )

x.hs:1:1: warning: [-Wmissing-signatures]
    Top-level binding with no type signature: x :: Char
Ok, modules loaded: Main (x.o).
Prelude Main> Prelude Describe Main> Ok, modules loaded: Main (x.o).
Prelude Main> Leaving GHCi.

Notice there is no warning about y despite the fact that we changed the file. In your commit, it will report that there's no top-level binding for y (because you're caching the old results).

You can also miss error messages due to this:

bash-3.2$ cat > input-no-errors.txt
:set -Wall -fobject-code
:!echo "x = 'a'" > x.hs
:l x.hs
:!echo "y = 'a' * k" > x.hs
:l x.hs
:q
bash-3.2$ cat input-no-errors.txt | ghci
GHCi, version 8.0.1: http://www.haskell.org/ghc/  :? for help
Prelude> Prelude> Prelude> [1 of 1] Compiling Main             ( x.hs, x.o )

x.hs:1:1: warning: [-Wmissing-signatures]
    Top-level binding with no type signature: x :: Char
Ok, modules loaded: Main (x.o).
Prelude Main> Prelude Describe Main> Ok, modules loaded: Main (x.o).
Prelude Main> Leaving GHCi.

There should be a type error or an out of scope error about k. There isn't because we changed the file too quickly. This happened to me a lot in Intero until I fixed it. We can put a delay before writing the file and then it works properly:

bash-3.2$ cat > input-delay.txt
:set -Wall -fobject-code
:!echo "x = 'a'" > x.hs
:l x.hs
:!sleep 1
:!echo "x = 'a' * k" > x.hs
:l x.hs
:q
bash-3.2$ cat input-delay.txt | ghci
GHCi, version 8.0.1: http://www.haskell.org/ghc/  :? for help
Prelude> Prelude> Prelude> [1 of 1] Compiling Main             ( x.hs, x.o )

x.hs:1:1: warning: [-Wmissing-signatures]
    Top-level binding with no type signature: x :: Char
Ok, modules loaded: Main (x.o).
Prelude Main> Prelude Main> Prelude Main> [1 of 1] Compiling Main             ( x.hs, x.o )

x.hs:1:11: error: Variable not in scope: k :: Char
Failed, modules loaded: none.
Prelude> Leaving GHCi.

For whatever reason in the GHC API, it ignores files that have changed in <1 second since the last modification.

Editing with flycheck turned on will trigger this a lot. If you just type check on a key binding or file save, you won't notice it that often.

from dante.

jyp avatar jyp commented on June 9, 2024

Thanks for the detailed information. I confirm that I am not observing this problem with my version of GHCi (8.0.2) on linux (nixos).

from dante.

chrisdone avatar chrisdone commented on June 9, 2024

It might be an OS X behavior then.

from dante.

jyp avatar jyp commented on June 9, 2024

from dante.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.