Skip to content

Commit ae7ed42

Browse files
Document GHC-94817 (#517)
* Document GHC-94817 Fixes #492. * Clarify confusion
1 parent dde07d0 commit ae7ed42

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: Tab character
3+
summary: A tab character occurred in the input file.
4+
flag: "-Wtabs"
5+
introduced: 9.6.1
6+
severity: warning
7+
---
8+
9+
Haskell's syntax is indentation-sensitive, which means that that a line's indentation is syntactically meaningful.
10+
Two characters are allowed for indentation: spaces and tabs.
11+
However, tab characters are defined [in the Haskell 2010 report](https://www.haskell.org/onlinereport/haskell2010/haskellch10.html) to insert enough spaces to reach the next column whose number is a multiple of 8.
12+
This does not match the way that many editors and other environments render tab characters, so without great care, the use of tabs can lead to confusing syntax errors.
13+
In particular, GHC may end up interpreting two lines that visually appear to have the same amount of indentation as being indented differently, or two lines that visually appear to be indented differently as having the same indentation.
14+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Tab where
2+
3+
add :: Int -> Int -> Int
4+
add x y =
5+
x + y
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Tab where
2+
3+
add :: Int -> Int -> Int
4+
add x y =
5+
x + y
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: A file that uses a tab for indentation
3+
---
4+
## Message
5+
```
6+
Tab.hs:5:1: warning: [-Wtabs] [GHC-94817]
7+
Tab character found here.
8+
Suggested fix: Please use spaces instead.
9+
|
10+
5 | x + y
11+
| ^^^^^^^^
12+
```
13+
14+
## Explanation
15+
16+
A tab character was found, which can be confusing.
17+
The warning can be addressed by replacing the tab with spaces.

0 commit comments

Comments
 (0)