forked from github-mirrors/ale
Handle ghc panic in haskell (#4145)
* Add primitive handling of ghc panic. * PascalCase in function. * Add simple test.
This commit is contained in:
parent
6c1f616c59
commit
1e997580fd
|
@ -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
|
||||
|
|
|
@ -130,3 +130,48 @@ Execute(The ghc handler should handle stack 1.5.1 output):
|
|||
\ ' 160 | pattern F :: Exp a',
|
||||
\ ' | ^^^^^',
|
||||
\ ])
|
||||
|
||||
Execute(The ghc handler should handle ghc panic):
|
||||
let g:detail = [
|
||||
\ '[15 of 15] Compiling SizedTypes.List',
|
||||
\ 'ghc: panic! (the ''impossible'' happened)',
|
||||
\ ' (GHC version 8.10.3:',
|
||||
\ ' src/SizedTypes/List.hs:(46,19)-(50,0) Specified type does not refine Haskell type for `SizedTypes.List.out` (Plugged Init types new)',
|
||||
\ ' The Liquid type',
|
||||
\ ' .',
|
||||
\ ' GHC.Types.Int -> (SizedTypes.List.List a) -> (_, (SizedTypes.List.List a))',
|
||||
\ ' .',
|
||||
\ ' is inconsistent with the Haskell type',
|
||||
\ ' .',
|
||||
\ ' forall p a ->',
|
||||
\ 'p -> SizedTypes.List.List a -> (a, SizedTypes.List.List a)',
|
||||
\ ' .',
|
||||
\ ' defined at src/SizedTypes/List.hs:52:1-3',
|
||||
\ ' .',
|
||||
\ ' Specifically, the Liquid component',
|
||||
\ ' .',
|
||||
\ ' {VV##0 : GHC.Types.Int | VV##0 >= 0}',
|
||||
\ ' .',
|
||||
\ ' is inconsistent with the Haskell component',
|
||||
\ ' .',
|
||||
\ ' p',
|
||||
\ ' .',
|
||||
\ ' ',
|
||||
\ ' HINT: Use the hole ''_'' instead of the mismatched component (in the Liquid specification)',
|
||||
\ '',
|
||||
\ 'Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug',
|
||||
\ '',
|
||||
\ ''
|
||||
\ ]
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 1,
|
||||
\ 'col': 1,
|
||||
\ 'type': 'E',
|
||||
\ 'text': 'ghc panic!',
|
||||
\ 'detail': join(g:detail[1:-3], "\n"),
|
||||
\ },
|
||||
\ ],
|
||||
\ ale#handlers#haskell#HandleGHCFormat(bufnr(''), g:detail)
|
||||
unlet g:detail
|
||||
|
|
Loading…
Reference in New Issue