Haskell lexer incorrectly labels type operators as characters.
Open
Nobody has claimed this yet.
S-major
T-bug
X-imported
- Dominant language
- Python
- Stars
- 2.2k
- Forks
- 885
- PR merge metrics
- No merged PRs in 30d
Description
(Original issue 1473 created by paamayim on 2018-09-08T19:33:42.558716+00:00)
The haskell lexer incorrect identifies the ' in a ': b as a character.
I've included a patch and testcase.
#!diff
diff -r 7941677dc77d pygments/lexers/haskell.py
--- a/pygments/lexers/haskell.py Mon Mar 13 19:16:03 2017 +0000
+++ b/pygments/lexers/haskell.py Sat Sep 08 15:27:18 2018 -0400
@@ -66,6 +66,7 @@
(r"(')[" + uni.Lu + r"][\w\']*", Keyword.Type),
(r"(')\[[^\]]*\]", Keyword.Type), # tuples and lists get special treatment in GHC
(r"(')\([^)]*\)", Keyword.Type), # ..
+ (r"(')[:!#$%&*+.\\/<=>?@^|~-]+", Keyword.Type), # promoted type operators
# Operators
(r'\\(?![:!#$%&*+.\\/<=>?@^|~-]+)', Name.Function), # lambda operator
(r'(<-|::|->|=>|=)(?![:!#$%&*+.\\/<=>?@^|~-]+)', Operator.Word), # specials
diff -r 7941677dc77d tests/examplefiles/example.hs
--- a/tests/examplefiles/example.hs Mon Mar 13 19:16:03 2017 +0000
+++ b/tests/examplefiles/example.hs Sat Sep 08 15:27:18 2018 -0400
@@ -39,3 +39,7 @@
type IntChar = '[Int, Char]
type Falsy = 'False
type Falsy = '(10, 20, 30)
+type EmptyList = '[]
+type TypeCons = 1 ': '[]
+type Times = 1 '* 2
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in pygments/lexers/haskell.py and inspect the Haskell lexer rules around promoted types and operators. Review tests/examplefiles/example.hs, then verify that examples such as 1 ': '[] and 1 '* 2 are classified as type operators rather than characters.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell, python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100