https://bugs.kde.org/show_bug.cgi?id=512318
Bug ID: 512318
Summary: Haskell syntax: Incorrect tokenization of backslash
operators and lambda expressions
Classification: Frameworks and Libraries
Product: frameworks-syntax-highlighting
Version First 6.20.0
Reported In:
Platform: unspecified
OS: All
Status: REPORTED
Severity: normal
Priority: NOR
Component: syntax
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Target Milestone: ---
STEPS TO REPRODUCE
1. Open a Haskell file in Kate/KWrite or use KSyntaxHighlighting to tokenize
Haskell code
2. Add code with backslash operators or lambda expressions, such as:
- Lambda: \x -> x
- Set difference: a \\ b
- Logical operators: a \/ b or a /\ b
- Custom operators: \+ 1 or \> x
3. Observe the tokenization (via syntax highlighting or tokenizer output)
OBSERVED RESULT
Backslash operators are incorrectly tokenized:
1. Lambda expressions: `\x -> x` - backslash and variable lumped together as
`"\x "` instead of separate tokens `\` and `x`
2. Set difference: `a \\ b` - entire expression lumped into one token or
incorrectly split
3. Logical OR: `a \/ b` - splits as `["a \\", "/", " b"]` instead of `[a, \/,
b]`
4. Logical AND: `a /\ b` - splits as `["a ", "/", "\\ b"]` instead of `[a,
/\, b]`
5. Custom operators: `\+ 1` - splits as `["\\", "+", " ", 1]` instead of
`[\+, 1]`
In import statements, operators are not tokenized at all: `import Data.List
(\\)` fails to recognize `\\` as an operator.
EXPECTED RESULT
Backslash operators should be tokenized as atomic operator tokens, matching
GHC's tokenizer behavior:
- Lambda: `\x -> x` → `[\, x, ->, x]`
- Set difference: `a \\ b` → `[a, \\, b]`
- Logical operators: `a \/ b` → `[a, \/, b]` and `a /\ b` → `[a, /\, b]`
- Custom operators: `\+ 1` → `[\+, 1]`
- Import operators: `import Data.List (\\)` → properly tokenized
SOFTWARE/OS VERSIONS
Linux/KDE Plasma: N/A (affects all platforms)
KDE Frameworks Version: All versions (issue in syntax definition XML)
Qt Version: N/A (syntax definition issue)
ADDITIONAL INFORMATION
Root cause in data/syntax/haskell.xml:
1. Line 476 (code context): The operator regex `[&symbolops;]+` doesn't
handle backslash operators atomically. The symbolops entity includes backslash
(\) but the pattern doesn't
account for backslash's special role in Haskell.
2. Lines 542-549 (import context): Completely missing operator matching
rules, so operators in import lists are not tokenized.
Impact: Affects Pandoc, Kate/KWrite, KSyntaxHighlighting users, documentation
generators, and code formatters.
Originally reported at: https://github.com/jgm/skylighting/issues/209
A fix has been prepared and will be submitted as a merge request to
https://invent.kde.org/frameworks/syntax-highlighting
--
You are receiving this mail because:
You are watching all bug changes.