vim-syntastic / syntastic

Syntax checking hacks for vim
Do What The F*ck You Want To Public License
11.3k stars 1.14k forks source link

solidity checker #2373

Closed randomlogin closed 3 years ago

randomlogin commented 3 years ago

Hi everyone! I'm trying to use solc for solidity files, however I cannot make it work, even after I spent several hours on it. I would be happy if someone can help me or forward me to some documentation I have missed.

So the problem: no errors are shown.

First of all, I have a .sol file which is correctly identified as a solidity file, next it indeed has some errors, as invoking solc a.sol outputs

Error: Expected identifier but got '}'
 --> a.sol:5:1:
  |
5 | }
  | ^

SyntasticInfo output:

Syntastic version: 3.10.0-27 (Vim 801, Linux, GUI)
Info for filetype: solidity
Global mode: active
Filetype solidity is active
The current file will be checked automatically
Available checkers: solc solhint
Currently enabled checker: solc
syntastic: 3.921074: &shell = '/bin/bash', &shellcmdflag = '-c', &shellpipe = '2>&1| tee', &shellquote = '', &shellredir = '>%s 2>&1', &shelltemp = 1, &shellxquote = '', &autochdir = 0, &shellxescape = ''

My syntastic-related .vimrc lines are:

let g:syntastic_solidity_checkers=['solc']
let g:syntastic_solidity_solc_exe=['/usr/bin/solc']
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_debug = 3
let g:syntastic_aggregate_errors = 1

Output of :mes after check:

syntastic: 0.018392: g:syntastic_version = '3.10.0-27 (Vim 801, Linux, GUI)'
syntastic: 0.018490: &shell = '/bin/bash', &shellcmdflag = '-c', &shellpipe = '2>&1| tee', &shellquote = '', &shellredir = '>%s 2>&1', &shelltemp = 1, &shellxquote = '', &autochdir = 0, &shellxescape = ''
syntastic: 0.018829: UpdateErrors (auto): default checkers
syntastic: 0.019032: CacheErrors: default checkers
syntastic: 0.019417: g:syntastic_aggregate_errors = 1
syntastic: 0.019548: getcwd() = '/home/shevtsov'
syntastic: 0.020694: CacheErrors: Invoking checker: solidity/solc
syntastic: 0.021102: SyntasticMake: called with options: {'errorformat': '%f:%l:%c: %trror: %m,%f:%l:%c: %tarning: %m', 'makeprg': '/usr/bin/solc a.sol'}
syntastic: 0.028131: system: command run in 0.006823s
syntastic: 0.028247: checker output: ['Error: Expected identifier but got ''}''', ' --> a.sol:5:1:', '  |', '5 | }', '  | ^', '', '']
syntastic: 0.028514: raw loclist: [{'lnum': 0, 'bufnr': 0, 'col': 0, 'valid': 0, 'vcol': 0, 'nr': -1, 'module': '', 'type': '', 'pattern': '', 'text': 'Error: Expected identifier but got ''}'''}, {'lnum': 0, 'bu
fnr': 0, 'col': 0, 'valid': 0, 'vcol': 0, 'nr': -1, 'module': '', 'type': '', 'pattern': '', 'text': ' --> a.sol:5:1:'}, {'lnum': 0, 'bufnr': 0, 'col': 0, 'valid': 0, 'vcol': 0, 'nr': -1, 'module': '', 'type': '
', 'pattern': '', 'text': '  |'}, {'lnum': 0, 'bufnr': 0, 'col': 0, 'valid': 0, 'vcol': 0, 'nr': -1, 'module': '', 'type': '', 'pattern': '', 'text': '5 | }'}, {'lnum': 0, 'bufnr': 0, 'col': 0, 'valid': 0, 'vcol
': 0, 'nr': -1, 'module': '', 'type': '', 'pattern': '', 'text': '  | ^'}, {'lnum': 0, 'bufnr': 0, 'col': 0, 'valid': 0, 'vcol': 0, 'nr': -1, 'module': '', 'type': '', 'pattern': '', 'text': ''}, {'lnum': 0, 'bu
fnr': 0, 'col': 0, 'valid': 0, 'vcol': 0, 'nr': -1, 'module': '', 'type': '', 'pattern': '', 'text': ''}]
syntastic: 0.028695: getLocList: checker solidity/solc returned 1
syntastic: 0.028777: solidity/solc raw: [{'lnum': 0, 'bufnr': 0, 'col': 0, 'valid': 0, 'vcol': 0, 'nr': -1, 'module': '', 'type': '', 'pattern': '', 'text': 'Error: Expected identifier but got ''}'''}, {'lnum':
0, 'bufnr': 0, 'col': 0, 'valid': 0, 'vcol': 0, 'nr': -1, 'module': '', 'type': '', 'pattern': '', 'text': ' --> a.sol:5:1:'}, {'lnum': 0, 'bufnr': 0, 'col': 0, 'valid': 0, 'vcol': 0, 'nr': -1, 'module': '', 'ty
pe': '', 'pattern': '', 'text': '  |'}, {'lnum': 0, 'bufnr': 0, 'col': 0, 'valid': 0, 'vcol': 0, 'nr': -1, 'module': '', 'type': '', 'pattern': '', 'text': '5 | }'}, {'lnum': 0, 'bufnr': 0, 'col': 0, 'valid': 0,
 'vcol': 0, 'nr': -1, 'module': '', 'type': '', 'pattern': '', 'text': '  | ^'}, {'lnum': 0, 'bufnr': 0, 'col': 0, 'valid': 0, 'vcol': 0, 'nr': -1, 'module': '', 'type': '', 'pattern': '', 'text': ''}, {'lnum':
0, 'bufnr': 0, 'col': 0, 'valid': 0, 'vcol': 0, 'nr': -1, 'module': '', 'type': '', 'pattern': '', 'text': ''}]
syntastic: 0.028968: quiet_messages filter: {}
syntastic: 0.029065: getLocList: checker solidity/solc run in 0.008274s
syntastic: 0.029244: aggregated: {'_sorted': 0, '_name': '', '_owner': 1, '_columns': 1, '_rawLoclist': []}
syntastic: 0.029403: sorted: {'_sorted': 1, '_name': '', '_owner': 1, '_columns': 1, '_rawLoclist': []}

From what I understand, the output of solc is successifully received, though it's not correctly shown. What is the problem? I've tried to play with options for aggregating, but no luck with it. I also have working python checker with this configuration.

lcd047 commented 3 years ago

What is the problem?

The problem is bit rot: solc has a "fast pace of change", syntastic's solc checker was written (by somebody else) in 2016, and you're hoping to still use it unchanged in 2021. Back in 2016 solc used to print each error on a single line, in 2021 errors seem to be spread over multiple lines as you show above. The other problem is syntastic is essentially dead these days (please consider using ALE instead, which takes advantage of Vim 8 features), and I don't know anything about solc, Solidity, or Ethereum in general. So if you insist to fix this you'll have to provide:

randomlogin commented 3 years ago

Switched to ALE, thanks.