Handle ghc panic in haskell (#4145)

* Add primitive handling of ghc panic.

* PascalCase in function.

* Add simple test.
This commit is contained in:
lykmast
2022-04-06 10:59:50 +03:00
committed by GitHub
parent 6c1f616c59
commit 1e997580fd
2 changed files with 63 additions and 0 deletions

View File

@@ -19,6 +19,16 @@ let s:temp_regex_prefix =
\ . substitute(s:temp_dir, '\\', '\\\\', 'g')
\ . '\.\{-}'
function! s:PanicOutput(lines) abort
return [{
\ 'lnum': 1,
\ 'col': 1,
\ 'text': 'ghc panic!',
\ 'type': 'E',
\ 'detail' : join(a:lines, "\n"),
\}]
endfunction
function! ale#handlers#haskell#HandleGHCFormat(buffer, lines) abort
" Look for lines like the following.
"
@@ -34,6 +44,14 @@ function! ale#handlers#haskell#HandleGHCFormat(buffer, lines) abort
let l:corrected_lines = []
" If ghc panic error, put the whole message in details and exit.
let l:panic_position = match(a:lines,'ghc: panic!')
let l:panic_end = match(a:lines,'Please report this as a GHC bug:')
if l:panic_position >= 0
return s:PanicOutput(a:lines[l:panic_position : l:panic_end])
endif
" Group the lines into smaller lists.
for l:line in a:lines
if len(matchlist(l:line, l:pattern)) > 0