c2hs
c2hs copied to clipboard
New line at the end of file is necessary?
Hi,
I have encountered a trouble when using c2hs. If the file is end of a {#fun#} binding and there's no new line at the end of file, an exception
c2hs: No match in record selector posRow
would be thrown. I'm wondering whether it's a bug, or just a feature?
A minimal case can be used to reproduce this bug:
#include <stdio.h>
{#fun variadic printf[const char *] as prints {`String', `String'} -> `()'#}
When add a new line at the end of file, c2hs would works well.
I can't reproduce. Which version are you using? You can get that with c2hs --version if installed globally or stack exec c2hs -- --version if installed via stack.
My c2hs executable is built from the latest source code on github (on Windows 10 64bit platform).
version:
C->Haskell Compiler, version 0.28.2 Switcheroo, 1 April 2016
build platform is "x86_64-mingw32" <1, True, True, 4>
git-rev: 29bd635c9e350992a47d6ec56002e8012619b19b
version of language-c: language-c-0.6
The following source file can be used to reproduce this error (sorry for upload a zip file because raw chs files are not permitted here):
When execute c2hs t1.chs, an error c2hs: No match in record selector posRow will occur. After add a new line at the end of t1.chs, c2hs will work well.
I was able to reproduce this issue on Windows 10 (but not on Linux). It appears to be an issue with Windows line endings. If I open and save t1.chs in MSYS2's vim package (which defaults to Unix line endings) it works fine even without having to add the extra line. However when I do the same in Notepad I have to work around the issue as you did.
In any case, this is a bug and I'll look into it further. Thanks very much for minimal use case.