argotorg / argotorg/solidity

Add line number and column to --standard-json sourceLocation

Open
#16,107 0 comments 4 reactions 0 assignees View on GitHub
feature
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
2d 19h
Merged PRs (30d)
29

Description

## Abstract

I am integrating `solc` as a linter into `vim`, using the `--standard-json` interface. Like most editors, Vim expects linter output to include precise **line** and **column** information for errors and warnings. Currently, `solc` only provides character offsets (`start` and `end`) in its `sourceLocation` object, which makes editor integration inefficient and error-prone.

## Motivation

Getting accurate line and column numbers from the following output requires external logic:

```json
{
"start": 1296,
"end": 1319,
"file": "contracts/BaseCollection.sol"
}
```

To convert offsets to line/column:

* The editor must read and parse the entire file.
* It must compute line breaks and offsets manually to map positions.

This adds complexity to every tool that consumes `solc` diagnostics, slows down linting workflows, and increases the potential for mismatches between source code views and diagnostic locations.

## Specification

Enhance the `sourceLocation` object in `--standard-json` output by optionally including the following keys:

```json
{
"file": "contracts/BaseCollection.sol",
"start": 1296,
"end": 1319,
"line_start": 42,
"column_start": 5,
"line_end": 43,
"column_end": 2
}
```

Where:

* `line_start` and `column_start` refer to the position of the `start` offset.
* `line_end` and `column_end` refer to the position of the `end` offset.
* All values are 1-based (like most editors and diagnostics protocols).

This format is compatible with common LSP, ALE, and IDE conventions.

## Backwards Compatibility

This proposal is fully backward-compatible:

* Existing tools using `start` and `end` will continue to work as-is.
* Tools that support `line_start`, `column_start`, etc., can use them directly for better UX.
* Fields are optional and additive.

Although some rigid tools may validate the schema strictly, it is reasonable to expect that long-term support for structured JSON diagnostics will allow for optional metadata fields.

Contributor guide

Open the contributing guide

Research direction

Start at the solc --standard-json diagnostic output that constructs the sourceLocation object. Trace how start and end offsets are produced, then identify the existing standard-json diagnostics checks to extend. Done means the output optionally includes the four 1-based line and column fields while preserving start, end, and file.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, solidity
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.