[commit: ghc] master: unlit: replace the SHEBANG with an empty line (c77b767)

git at git.haskell.org git at git.haskell.org
Mon Mar 13 21:06:34 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/c77b767098be53087e0b06ba23d613dd7c3bcf8e/ghc

>---------------------------------------------------------------

commit c77b767098be53087e0b06ba23d613dd7c3bcf8e
Author: Phil Ruffwind <rf at rufflewind.com>
Date:   Mon Mar 13 15:17:47 2017 -0400

    unlit: replace the SHEBANG with an empty line
    
    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


>---------------------------------------------------------------

c77b767098be53087e0b06ba23d613dd7c3bcf8e
 testsuite/tests/parser/should_fail/T13414.lhs    | 3 +++
 testsuite/tests/parser/should_fail/T13414.stderr | 2 ++
 testsuite/tests/parser/should_fail/all.T         | 1 +
 utils/unlit/unlit.c                              | 3 +++
 4 files changed, 9 insertions(+)

diff --git a/testsuite/tests/parser/should_fail/T13414.lhs b/testsuite/tests/parser/should_fail/T13414.lhs
new file mode 100644
index 0000000..fe6b960
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/T13414.lhs
@@ -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
index 0000000..f5b0001
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/T13414.stderr
@@ -0,0 +1,2 @@
+
+T13414.lhs:3:10: error: Variable not in scope: invalid_ident_
diff --git a/testsuite/tests/parser/should_fail/all.T b/testsuite/tests/parser/should_fail/all.T
index 1496fec..b897484 100644
--- a/testsuite/tests/parser/should_fail/all.T
+++ b/testsuite/tests/parser/should_fail/all.T
@@ -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, [''])
diff --git a/utils/unlit/unlit.c b/utils/unlit/unlit.c
index c0e3b98..9a697eb 100644
--- a/utils/unlit/unlit.c
+++ b/utils/unlit/unlit.c
@@ -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)



More information about the ghc-commits mailing list