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

Updating static files never triggers recompilation #118

Closed
snoyberg opened this issue Sep 7, 2013 · 6 comments
Closed

Updating static files never triggers recompilation #118

snoyberg opened this issue Sep 7, 2013 · 6 comments

Comments

@snoyberg
Copy link
Member

snoyberg commented Sep 7, 2013

This seems to be a resurfacing of #94. Using the same code from that issue (slightly updated to include SessionInitParams):

{-# LANGUAGE OverloadedStrings #-}

module Main where

import IdeSession
import Data.Monoid (mconcat)
import qualified Data.ByteString.Lazy.Char8 as L8

main :: IO ()
main = do
    sess <- initSession (SessionInitParams Nothing) defaultSessionConfig
                { configDir             = "."
                }

    let cb = \_ -> return ()
        update = flip (updateSession sess) cb

    let mainContents = L8.pack $ unlines
            [ "{-# LANGUAGE TemplateHaskell #-}"
            , "import Text.Hamlet"
            , "import Text.Blaze.Html.Renderer.String"
            , "main = putStrLn $ renderHtml $(shamletFile \"foo.hamlet\")"
            ]

    update $ mconcat
        [ updateModule "Main.hs" mainContents
        , updateDataFile "foo.hamlet" "<p invalid"
        ]

    -- Error message expected, invalid data file
    getSourceErrors sess >>= print

    update $ updateDataFile "foo.hamlet" "<p>Valid"

    -- No error message expected, but got one anyway
    getSourceErrors sess >>= print

    update $ updateModule "Main.hs" $ mainContents `L8.append` "\n\n-- Trigger a recompile"
    -- No more error message
    getSourceErrors sess >>= print

    update $ updateDataFile "foo.hamlet" "<p invalid"

    -- Error message expected, but recompilation is not triggered.
    getSourceErrors sess >>= print

I would expect the last set of error messages to be non-empty due to the invalid Hamlet syntax. Instead, I'm getting no error messages. This seems to be the cause of a production bug: fpco/fpco#2338.

Pinging @jwiegley, we should make sure to get an isolation-runner test for this.

@Mikolaj
Copy link
Collaborator

Mikolaj commented Sep 7, 2013

To make sure and leave a link: I suppose the (ide-backend and perhaps your own?) tests for #94 pass OK on your system? (I mean the following tests: 1169525)

@snoyberg
Copy link
Member Author

snoyberg commented Sep 8, 2013

When I run locally, all tests pass. I haven't looked at the individual test cases that are run.

@snoyberg
Copy link
Member Author

I've confirmed that this occurs even without Hamlet being involved:

{-# LANGUAGE OverloadedStrings #-}

module Main where

import IdeSession
import Data.Monoid (mconcat)
import qualified Data.ByteString.Lazy.Char8 as L8

main :: IO ()
main = do
    sess <- initSession (SessionInitParams Nothing) defaultSessionConfig
                { configDir             = "."
                }

    let cb = \_ -> return ()
        update = flip (updateSession sess) cb

    let mainContents = L8.pack $ unlines
            [ "{-# LANGUAGE TemplateHaskell #-}"
            , "import Language.Haskell.TH.Syntax"
            , "main = print ($(do"
            , "  qAddDependentFile \"foo.hamlet\""
            , "  s <- qRunIO $ readFile \"foo.hamlet\""
            , "  lift $ (read s :: Int)"
            , "  ) :: Int)"
            ]

    update $ mconcat
        [ updateModule "Main.hs" mainContents
        , updateDataFile "foo.hamlet" "invalid"
        ]

    -- Error message expected, invalid data file
    getSourceErrors sess >>= print . length

    update $ updateDataFile "foo.hamlet" "42"

    -- No error message expected, but got one anyway
    getSourceErrors sess >>= print . length

    update $ updateModule "Main.hs" $ mainContents `L8.append` "\n\n-- Trigger a recompile"
    -- No more error message
    getSourceErrors sess >>= print . length

    update $ updateDataFile "foo.hamlet" "invalid"

    -- Error message expected, but recompilation is not triggered.
    getSourceErrors sess >>= print . length

@edsko
Copy link
Collaborator

edsko commented Oct 16, 2013

Just for the record, this is a problem with ghc itself; see also https://github.com/fpco/fpco/issues/2338.

@dcoutts
Copy link
Collaborator

dcoutts commented Oct 30, 2013

We now have a fix for this (ie fix to ghc) in our experimental branch. See also #134 however.

edsko added a commit that referenced this issue Nov 18, 2013
@edsko
Copy link
Collaborator

edsko commented Nov 18, 2013

Confirmed that this is resolved by the ghc patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants