haskell / c2hs

c2hs is a pre-processor for Haskell FFI bindings to C libraries
http://hackage.haskell.org/package/c2hs
Other
199 stars 50 forks source link

c2hs always fails with "Prelude.head: empty list" #237

Closed arsdragonfly closed 5 years ago

arsdragonfly commented 5 years ago

Using the simple test in tests/system/simple:

$ c2hs -d trace Simple.chs
Attempting to read file `Simple.chs'...
...parsing `Simple'...
...successfully loaded `Simple'.
Invoking cpp as `cpp -x c -U__BLOCKS__ -DC2HS_VERSION_MAJOR=0 -DC2HS_VERSION_MINOR=28 -DC2HS_VERSION_REV=6 Simple.chs.h'...
Attempting to read file `Simple.i'...
...parsing `Simple.i'...
c2hs: Prelude.head: empty list

running with -d chs yields

-- GENERATED by C->Haskell Compiler, version 0.28.6 Switcheroo, 25 November 2017 (C->HS binding
)
-- Edit the ORIGNAL .chs file instead!

{-# LINE 1 "Simple.chs" #-}
module Main
where

main :: IO ()
main  = {#call foo#}
{-# LINE 5 "Simple.chs" #-}

I suspect it's a different issue from #192

arsdragonfly commented 5 years ago

Ignore the previous backtrace; here's the correct one

./dist/build/c2hs/c2hs tests/system/simple/Simple.chs +RTS -xc                     master ✗
*** Exception (reporting due to +RTS -xc): (THUNK_STATIC), stack trace: 
  Control.StateTrans.liftIO.\,
  called from Control.StateTrans.liftIO,
  called from Control.StateBase.liftIO,
  called from Control.StateBase.+>=.\,
  called from Control.StateTrans.+>=.\.\.(...),
  called from Control.StateTrans.+>=.\.\,
  called from Control.StateTrans.+>=.\,
  called from Control.StateTrans.+>=,
  called from Control.StateBase.+>=,
  called from Main.compile,
  called from Control.StateTrans.fatalsHandledBy.\,
  called from Control.StateTrans.fatalsHandledBy,
  called from Control.State.fatalsHandledBy,
  called from Control.StateBase.unpackCST,
  called from Control.State.run.m,
  called from Control.StateTrans.runSTB,
  called from Control.State.run,
  called from C2HS.State.runC2HS,
  called from Main.main
*** Exception (reporting due to +RTS -xc): (THUNK), stack trace: 
  Control.StateTrans.liftIO.\,
  called from Control.StateTrans.liftIO,
  called from Control.StateBase.liftIO,
  called from System.CIO.createDirectoryIfMissing,
  called from Main.process,
  called from Main.execute,
  called from Main.compile.doExecute,
  called from Control.StateBase.+>=.\,
  called from Control.StateTrans.+>=.\.\.(...),
  called from Control.StateTrans.+>=.\.\,
  called from Control.StateTrans.+>=.\,
  called from Control.StateTrans.+>=,
  called from Control.StateBase.+>=,
  called from Main.compile,
  called from Control.StateTrans.fatalsHandledBy.\,
  called from Control.StateTrans.fatalsHandledBy,
  called from Control.State.fatalsHandledBy,
  called from Control.StateBase.unpackCST,
  called from Control.State.run.m,
  called from Control.StateTrans.runSTB,
  called from Control.State.run,
  called from C2HS.State.runC2HS,
  called from Main.main
*** Exception (reporting due to +RTS -xc): (THUNK), stack trace: 
  Control.StateTrans.liftIO.\,
  called from Control.StateTrans.liftIO,
  called from Control.StateBase.liftIO,
  called from System.CIO.createDirectoryIfMissing,
  called from Main.process,
  called from Main.execute,
  called from Main.compile.doExecute,
  called from Control.StateBase.+>=.\,
  called from Control.StateTrans.+>=.\.\.(...),
  called from Control.StateTrans.+>=.\.\,
  called from Control.StateTrans.+>=.\,
  called from Control.StateTrans.+>=,
  called from Control.StateBase.+>=,
  called from Main.compile,
  called from Control.StateTrans.fatalsHandledBy.\,
  called from Control.StateTrans.fatalsHandledBy,
  called from Control.State.fatalsHandledBy,
  called from Control.StateBase.unpackCST,
  called from Control.State.run.m,
  called from Control.StateTrans.runSTB,
  called from Control.State.run,
  called from C2HS.State.runC2HS,
  called from Main.main
*** Exception (reporting due to +RTS -xc): (THUNK_1_0), stack trace: 
  GHC.List.CAF
  --> evaluated by: Language.C.Parser.Lexer.lexC,
  called from Language.C.Parser.ParserMonad.execParser,
  called from C2HS.C.parseHeader,
  called from C2HS.C.loadAttrC,
  called from Main.process,
  called from Main.execute,
  called from Main.compile.doExecute,
  called from Control.StateBase.+>=.\,
  called from Control.StateTrans.+>=.\.\.(...),
  called from Control.StateTrans.+>=.\.\,
  called from Control.StateTrans.+>=.\,
  called from Control.StateTrans.+>=,
  called from Control.StateBase.+>=,
  called from Main.compile,
  called from Control.StateTrans.fatalsHandledBy.\,
  called from Control.StateTrans.fatalsHandledBy,
  called from Control.State.fatalsHandledBy,
  called from Control.StateBase.unpackCST,
  called from Control.State.run.m,
  called from Control.StateTrans.runSTB,
  called from Control.State.run,
  called from C2HS.State.runC2HS,
  called from Main.main
*** Exception (reporting due to +RTS -xc): (base:GHC.Exception.Type.SomeException), stack trace: 
  Control.StateTrans.fatalsHandledBy.\,
  called from Control.StateTrans.fatalsHandledBy,
  called from Control.State.fatalsHandledBy,
  called from Control.StateBase.unpackCST,
  called from Control.State.run.m,
  called from Control.StateTrans.runSTB,
  called from Control.State.run,
  called from C2HS.State.runC2HS,
  called from Main.main,
  called from GHC.List.CAF
*** Exception (reporting due to +RTS -xc): (base:GHC.Exception.Type.SomeException), stack trace: 
  Control.StateTrans.fatalsHandledBy.\,
  called from Control.StateTrans.fatalsHandledBy,
  called from Control.State.fatalsHandledBy,
  called from Control.StateBase.unpackCST,
  called from Control.State.run.m,
  called from Control.StateTrans.runSTB,
  called from Control.State.run,
  called from C2HS.State.runC2HS,
  called from Main.main,
  called from GHC.List.CAF
c2hs: Prelude.head: empty list
arsdragonfly commented 5 years ago

failing all of the test cases with the same error

arsdragonfly commented 5 years ago

See #238 .