#7277: Recompilation check fails for TH unless functions are inlined -----------------------------------------+---------------------------------- Reporter: orenbenkiki | Owner: Type: bug | Status: new Priority: normal | Component: Template Haskell Version: 7.4.2 | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: Incorrect result at runtime | Testcase: Blockedby: | Blocking: Related: 481 | -----------------------------------------+---------------------------------- Even though [http://hackage.haskell.org/trac/ghc/ticket/481 Issue 481] is marked as closed, the fix is only partial. If a function inside $( ... ) is not inlined, then the dependency check fails. Attached is a full example, built around the following code:
{{{ #ifdef NO_INLINE {-# NOINLINE libraryFunction #-} #endif libraryFunction :: Q Exp libraryFunction = [e| "Return X" |] }}} And the test: {{{ case_library_function = $( libraryFunction ) @?= "Return A" }}} Here is are the relevant parts of RUNME.LOG: {{{ + rm -rf dist + cabal configure --enable-tests Resolving dependencies... Configuring dependency-bug-0.0.1... + sed -e 's/Return ./Return A/' -i src/Dependency/Library.hs + cabal build Building dependency-bug-0.0.1... Preprocessing library dependency-bug-0.0.1... [1 of 1] Compiling Dependency.Library ( src/Dependency/Library.hs, dist/build/Dependency/Library.o ) [1 of 1] Compiling Dependency.Library ( src/Dependency/Library.hs, dist/build/Dependency/Library.p_o ) Registering dependency-bug-0.0.1... Preprocessing test suite 'Test' for dependency-bug-0.0.1... [1 of 1] Compiling Main ( test/Main.hs, dist/build/Test/Test- tmp/Main.o ) Linking dist/build/Test/Test ... + cabal test Running 1 test suites... Test suite Test: RUNNING... Test suite Test: PASS Test suite logged to: dist/test/dependency-bug-0.0.1-Test.log 1 of 1 test suites (1 of 1 test cases) passed. + sed -e 's/Return ./Return B/' -i src/Dependency/Library.hs + cabal build Building dependency-bug-0.0.1... Preprocessing library dependency-bug-0.0.1... [1 of 1] Compiling Dependency.Library ( src/Dependency/Library.hs, dist/build/Dependency/Library.o ) [1 of 1] Compiling Dependency.Library ( src/Dependency/Library.hs, dist/build/Dependency/Library.p_o ) Registering dependency-bug-0.0.1... Preprocessing test suite 'Test' for dependency-bug-0.0.1... [1 of 1] Compiling Main ( test/Main.hs, dist/build/Test/Test- tmp/Main.o ) Linking dist/build/Test/Test ... + cabal test Running 1 test suites... Test suite Test: RUNNING... Main: library function: [Failed] expected: "Return A" but got: "Return B" Test Cases Total Passed 0 0 Failed 1 1 Total 1 1 Test suite Test: FAIL Test suite logged to: dist/test/dependency-bug-0.0.1-Test.log 0 of 1 test suites (0 of 1 test cases) passed. }}} This is as expected; we changed the source to "Return B" but the test expects the library to "Return A" so it fails. So far, so good. However: {{{ + rm -rf dist + cabal configure --enable-tests -fwithout-inline Resolving dependencies... Configuring dependency-bug-0.0.1... + sed -e 's/Return ./Return A/' -i src/Dependency/Library.hs + cabal build Building dependency-bug-0.0.1... Preprocessing library dependency-bug-0.0.1... [1 of 1] Compiling Dependency.Library ( src/Dependency/Library.hs, dist/build/Dependency/Library.o ) [1 of 1] Compiling Dependency.Library ( src/Dependency/Library.hs, dist/build/Dependency/Library.p_o ) Registering dependency-bug-0.0.1... Preprocessing test suite 'Test' for dependency-bug-0.0.1... [1 of 1] Compiling Main ( test/Main.hs, dist/build/Test/Test- tmp/Main.o ) Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Loading package array-0.4.0.0 ... linking ... done. Loading package deepseq-1.3.0.0 ... linking ... done. Loading package containers-0.4.2.1 ... linking ... done. Loading package pretty-1.1.1.0 ... linking ... done. Loading package template-haskell ... linking ... done. Loading package dependency-bug-0.0.1 ... linking ... done. Loading package filepath-1.3.0.0 ... linking ... done. Loading package old-locale-1.0.0.4 ... linking ... done. Loading package old-time-1.1.0.0 ... linking ... done. Loading package bytestring-0.9.2.1 ... linking ... done. Loading package unix-2.5.1.1 ... linking ... done. Loading package directory-1.1.0.2 ... linking ... done. Loading package cpphs-1.14 ... linking ... done. Loading package haskell-src-exts-1.13.5 ... linking ... done. Loading package transformers-0.3.0.0 ... linking ... done. Loading package mtl-2.1.2 ... linking ... done. Loading package regex-base-0.93.2 ... linking ... done. Loading package regex-posix-0.95.2 ... linking ... done. Loading package language-haskell-extract-0.2.1 ... linking ... done. Loading package ansi-terminal-0.5.5 ... linking ... done. Loading package ansi-wl-pprint-0.6.4 ... linking ... done. Loading package extensible-exceptions-0.1.1.4 ... linking ... done. Loading package hostname-1.0 ... linking ... done. Loading package time-1.4 ... linking ... done. Loading package random-1.0.1.1 ... linking ... done. Loading package text-0.11.2.3 ... linking ... done. Loading package xml-1.3.12 ... linking ... done. Loading package test-framework-0.6.1 ... linking ... done. Loading package test-framework-th-0.2.2 ... linking ... done. Loading package HUnit-1.2.5.1 ... linking ... done. Loading package test-framework-hunit-0.2.7 ... linking ... done. Linking dist/build/Test/Test ... + cabal test Running 1 test suites... Test suite Test: RUNNING... Test suite Test: PASS Test suite logged to: dist/test/dependency-bug-0.0.1-Test.log 1 of 1 test suites (1 of 1 test cases) passed. + sed -e 's/Return ./Return B/' -i src/Dependency/Library.hs + cabal build Building dependency-bug-0.0.1... Preprocessing library dependency-bug-0.0.1... [1 of 1] Compiling Dependency.Library ( src/Dependency/Library.hs, dist/build/Dependency/Library.o ) [1 of 1] Compiling Dependency.Library ( src/Dependency/Library.hs, dist/build/Dependency/Library.p_o ) Registering dependency-bug-0.0.1... Preprocessing test suite 'Test' for dependency-bug-0.0.1... Linking dist/build/Test/Test ... + cabal test Running 1 test suites... Test suite Test: RUNNING... Test suite Test: PASS Test suite logged to: dist/test/dependency-bug-0.0.1-Test.log 1 of 1 test suites (1 of 1 test cases) passed. }}} As you can see, without-inline the 2nd build did not recompile the test, even though it should have. It only re-linked the test, so it kept seeing "Return A" even though the library actually does "Return B". In my real code, there are no NO/INLINE pragmas; however, the TH code is complex enough that it is not inlined, which causes the same problem. I had to use the pragma to keep the example short. -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7277> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler _______________________________________________ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs