Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solidity solc linter syntax error sometimes incorrectly parses line numbrer #4896

Open
bogdan opened this issue Jan 19, 2025 · 0 comments
Open
Labels

Comments

@bogdan
Copy link

bogdan commented Jan 19, 2025

Information

VIM version

NVIM 0.10.2

Operating System:

Darwin prakriti.local 24.2.0 Darwin Kernel Version 24.2.0: Fri Dec 6 19:01:59 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T6000 arm64

What went wrong

Line number and file name for solidity error are parsed incorrectly.
All errors put to current buffer while they may relate to different files.

Reproducing the bug

Make solidity error with the note like so:

Error: Derived contract must override function "_msgData". Two or more base classes define function with same name and parameter types.
  --> contracts/BaseCollection.sol:16:1:
   |
16 | abstract contract BaseCollection is ERC721BurnableUpgradeable, MinterCheckers, EmbeddedForwarder {
   | ^ (Relevant source part starts here and spans across multiple lines).
Note: Definition in "ContextUpgradeable":
  --> ./node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:27:5:
   |
27 |     function _msgData() internal view virtual returns (bytes calldata) {
   |     ^ (Relevant source part starts here and spans across multiple lines).
Note: Definition in "EmbeddedForwarder":
  --> contracts/utils/EmbeddedForwarder.sol:18:5:
   |
18 |     function _msgData() internal view override(ContextUpgradeable, ERC2771ContextUpgradeable) returns (bytes calldata) {
   |     ^ (Relevant source part starts here and spans across multiple lines).

TypeError: Derived contract must override function "_contextSuffixLength". Two or more base classes define function with same name and parameter types.
  --> contracts/Test.sol:18:1:
   |
18 | contract Test is ERC721BurnableUpgradeable, EmbeddedForwarder  {
   | ^ (Relevant source part starts here and spans across multiple lines).
Note: Definition in "ContextUpgradeable":
  --> @openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:31:5:
   |
31 |     function _contextSuffixLength() internal view virtual returns (uint256) {
   |     ^ (Relevant source part starts here and spans across multiple lines).
Note: Definition in "EmbeddedForwarder":
  --> contracts/utils/EmbeddedForwarder.sol:22:5:
   |
22 |     function _contextSuffixLength() internal view override(ContextUpgradeable, ERC2771ContextUpgradeable) returns (uint256) {
   |     ^ (Relevant source part starts here and spans across multiple lines).

The error line numbers are parsed as 22 but not 18.
As per contracts/utils/EmbeddedForwarder.sol:22:5 but not contracts/Test.sol:18:1

:ALEInfo

Expand Current Filetype: solidity Available Linters: ['solc', 'solhint', 'solium'] Enabled Linters: ['solc'] Ignored Linters: [] Suggested Fixers: 'forge' - Fix Solidity files with forge fmt. 'remove_trailing_lines' - Remove all blank lines at the end of a file. 'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.

Linter Variables:
" Press Space to read :help for a setting
let g:ale_solidity_solc_executable = 'solc'
let g:ale_solidity_solc_options = '--allow-paths=. @OpenZeppelin=./node_modules/@OpenZeppelin hardhat=./node_modules/hardhat'

Global Variables:
" Press Space to read :help for a setting
let g:ale_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = v:null
let g:ale_command_wrapper = ''
let g:ale_completion_delay = 100
let g:ale_completion_enabled = 1
let g:ale_completion_max_suggestions = 50
let g:ale_disable_lsp = 'auto'
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%code: %%s'
let g:ale_echo_msg_info_str = 'Info'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 0
let g:ale_fixers = {}
let g:ale_history_enabled = 1
let g:ale_info_default_mode = 'preview'
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 1
let g:ale_lint_on_filetype_changed = 1
let g:ale_lint_on_insert_leave = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'never'
let g:ale_linter_aliases = {}
let g:ale_linters = {}
let b:ale_linters = ['solc']
let g:ale_linters_explicit = 0
let g:ale_linters_ignore = {}
let g:ale_list_vertical = 0
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '%code: %%s'
let g:ale_max_buffer_history_size = 20
let g:ale_max_signs = v:null
let g:ale_maximum_file_size = v:null
let g:ale_open_list = 0
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_root = {}
let g:ale_set_balloons = 0
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 1
let g:ale_sign_column_always = v:null
let g:ale_sign_error = v:null
let g:ale_sign_info = v:null
let g:ale_sign_offset = v:null
let g:ale_sign_style_error = v:null
let g:ale_sign_style_warning = v:null
let g:ale_sign_warning = v:null
let g:ale_sign_highlight_linenrs = v:null
let g:ale_type_map = {}
let g:ale_use_neovim_diagnostics_api = 1
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 'all'
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1

Command History:

(finished - exit code 1) ['/bin/zsh', '-c', 'solc --allow-paths=. @OpenZeppelin=./node_modules/@OpenZeppelin hardhat=./node_modules/hardhat ''/Users/bogdan/makabu/brad/realphotos-contracts/contracts/Test.sol'' < ''/var/folders/gd/qqwx5zqx1wx1pxq5s72hzkdh0000gn/T/nvim.bogdan/s39VP5/2025/Test.sol''']

<<>>

<<>>
Error: Derived contract must override function "_contextSuffixLength". Two or more base classes define function with same name and parameter types.
--> contracts/BaseCollection.sol:16:1:
|
16 | abstract contract BaseCollection is ERC721BurnableUpgradeable, MinterCheckers, EmbeddedForwarder {
| ^ (Relevant source part starts here and spans across multiple lines).
Note: Definition in "ContextUpgradeable":
--> ./node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:31:5:
|
31 | function _contextSuffixLength() internal view virtual returns (uint256) {
| ^ (Relevant source part starts here and spans across multiple lines).
Note: Definition in "EmbeddedForwarder":
--> contracts/utils/EmbeddedForwarder.sol:22:5:
|
22 | function _contextSuffixLength() internal view override(ContextUpgradeable, ERC2771ContextUpgradeable) returns (uint256) {
| ^ (Relevant source part starts here and spans across multiple lines).

Error: Derived contract must override function "_msgData". Two or more base classes define function with same name and parameter types.
--> contracts/BaseCollection.sol:16:1:
|
16 | abstract contract BaseCollection is ERC721BurnableUpgradeable, MinterCheckers, EmbeddedForwarder {
| ^ (Relevant source part starts here and spans across multiple lines).
Note: Definition in "ContextUpgradeable":
--> ./node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:27:5:
|
27 | function _msgData() internal view virtual returns (bytes calldata) {
| ^ (Relevant source part starts here and spans across multiple lines).
Note: Definition in "EmbeddedForwarder":
--> contracts/utils/EmbeddedForwarder.sol:18:5:
|
18 | function _msgData() internal view override(ContextUpgradeable, ERC2771ContextUpgradeable) returns (bytes calldata) {
| ^ (Relevant source part starts here and spans across multiple lines).

Error: Derived contract must override function "_msgSender". Two or more base classes define function with same name and parameter types.
--> contracts/BaseCollection.sol:16:1:
|
16 | abstract contract BaseCollection is ERC721BurnableUpgradeable, MinterCheckers, EmbeddedForwarder {
| ^ (Relevant source part starts here and spans across multiple lines).
Note: Definition in "ContextUpgradeable":
--> ./node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:23:5:
|
23 | function _msgSender() internal view virtual returns (address) {
| ^ (Relevant source part starts here and spans across multiple lines).
Note: Definition in "EmbeddedForwarder":
--> contracts/utils/EmbeddedForwarder.sol:14:5:
|
14 | function _msgSender() internal view override(ContextUpgradeable, ERC2771ContextUpgradeable) returns (address) {
| ^ (Relevant source part starts here and spans across multiple lines).

Error: Base constructor arguments given twice.
--> contracts/BaseCollection.sol:34:19:
|
34 | constructor() ERC2771ContextUpgradeable(address(this)) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Note: Second constructor call is here:
--> contracts/utils/EmbeddedForwarder.sol:11:19:
|
11 | constructor() ERC2771ContextUpgradeable(address(this)) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Error: Derived contract must override function "_contextSuffixLength". Two or more base classes define function with same name and parameter types.
--> contracts/Test.sol:18:1:
|
18 | contract Test is ERC721BurnableUpgradeable, EmbeddedForwarder {
| ^ (Relevant source part starts here and spans across multiple lines).
Note: Definition in "ContextUpgradeable":
--> ./node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:31:5:
|
31 | function _contextSuffixLength() internal view virtual returns (uint256) {
| ^ (Relevant source part starts here and spans across multiple lines).
Note: Definition in "EmbeddedForwarder":
--> contracts/utils/EmbeddedForwarder.sol:22:5:
|
22 | function _contextSuffixLength() internal view override(ContextUpgradeable, ERC2771ContextUpgradeable) returns (uint256) {
| ^ (Relevant source part starts here and spans across multiple lines).

Error: Derived contract must override function "_msgData". Two or more base classes define function with same name and parameter types.
--> contracts/Test.sol:18:1:
|
18 | contract Test is ERC721BurnableUpgradeable, EmbeddedForwarder {
| ^ (Relevant source part starts here and spans across multiple lines).
Note: Definition in "ContextUpgradeable":
--> ./node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:27:5:
|
27 | function _msgData() internal view virtual returns (bytes calldata) {
| ^ (Relevant source part starts here and spans across multiple lines).
Note: Definition in "EmbeddedForwarder":
--> contracts/utils/EmbeddedForwarder.sol:18:5:
|
18 | function _msgData() internal view override(ContextUpgradeable, ERC2771ContextUpgradeable) returns (bytes calldata) {
| ^ (Relevant source part starts here and spans across multiple lines).

Error: Derived contract must override function "_msgSender". Two or more base classes define function with same name and parameter types.
--> contracts/Test.sol:18:1:
|
18 | contract Test is ERC721BurnableUpgradeable, EmbeddedForwarder {
| ^ (Relevant source part starts here and spans across multiple lines).
Note: Definition in "ContextUpgradeable":
--> ./node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:23:5:
|
23 | function _msgSender() internal view virtual returns (address) {
| ^ (Relevant source part starts here and spans across multiple lines).
Note: Definition in "EmbeddedForwarder":
--> contracts/utils/EmbeddedForwarder.sol:14:5:
|
14 | function _msgSender() internal view override(ContextUpgradeable, ERC2771ContextUpgradeable) returns (address) {
| ^ (Relevant source part starts here and spans across multiple lines).

<<>>

@bogdan bogdan added the bug label Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant