unlit: replace the SHEBANG with an empty line
authorPhil Ruffwind <rf@rufflewind.com>
Mon, 13 Mar 2017 19:17:47 +0000 (15:17 -0400)
committerBen Gamari <ben@smart-cactus.org>
Mon, 13 Mar 2017 19:17:47 +0000 (15:17 -0400)
This corrects the line numbers for literate code after a shebang.
Fixes #13414.

Test Plan: validate

Reviewers: austin, bgamari, trofi

Reviewed By: bgamari, trofi

Subscribers: trofi, rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3333

testsuite/tests/parser/should_fail/T13414.lhs [new file with mode: 0644]
testsuite/tests/parser/should_fail/T13414.stderr [new file with mode: 0644]
testsuite/tests/parser/should_fail/all.T
utils/unlit/unlit.c

diff --git a/testsuite/tests/parser/should_fail/T13414.lhs b/testsuite/tests/parser/should_fail/T13414.lhs
new file mode 100644 (file)
index 0000000..fe6b960
--- /dev/null
@@ -0,0 +1,3 @@
+#!/usr/bin/env runhaskell
+> module T13414 where
+> main = invalid_ident_
diff --git a/testsuite/tests/parser/should_fail/T13414.stderr b/testsuite/tests/parser/should_fail/T13414.stderr
new file mode 100644 (file)
index 0000000..f5b0001
--- /dev/null
@@ -0,0 +1,2 @@
+
+T13414.lhs:3:10: error: Variable not in scope: invalid_ident_
index 1496fec..b897484 100644 (file)
@@ -97,3 +97,4 @@ test('T12051', normal, compile_fail, [''])
 test('T12429', normal, compile_fail, [''])
 test('T12811', normal, compile_fail, [''])
 test('T13260', normal, compile_fail, [''])
+test('T13414', literate, compile_fail, [''])
index c0e3b98..9a697eb 100644 (file)
@@ -296,6 +296,9 @@ static void unlit(char *file, FILE *istream, FILE *ostream)
            }
        }
 #endif
+       if (this == SHEBANG) {
+           myputc('\n', ostream);
+       }
     } while(this!=ENDFILE);
 
     if (defnsread==0)