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

Enrich label custom reporting data #1152

Merged
merged 5 commits into from
Mar 3, 2023
Merged

Enrich label custom reporting data #1152

merged 5 commits into from
Mar 3, 2023

Conversation

yannham
Copy link
Member

@yannham yannham commented Mar 1, 2023

First step of #1052. Enrich the label interface for custom error reporting, with the additional notes field. Put this field, together with the previous tag (now message) to a dedicated data structure, ContractDiagnostic. Finally, Label now stores a stack of such diagnostic, to help fix one issue of #1052 which is that subcontract might erase the message previously set by parent contract, although it could be relevant.

This PR doesn't add any primop to access this new interface yet: it mostly update the error reporting code to handle it. Adding primops is postponed to a subsequent PR.

I'm not totally sure yet what should go in the ContractDiagnostics (should we also include type_path and arg_idx, to store the type path and argument to parent contracts as well, and enrich the corresponding "parent" diagnostics) ?. Should we add more fields than notes to the label interface?.

However, those questions need not be answered right away. We can improve later in a backward compatible manner: for now, the plan is to add at least notes to make it accessible to the user (in a subsequent PR), with a backward-compatible API. We can always:

  • add more fields later (hints/suggestions, for example, or the label of the contract argument)
  • move things form Label to ContractDiagnostic, allowing to store a stack of value instead of just the latest one, to improve the reporting of blame errors that have several contract diagnostics. This is invisible to user code, and thus can't break backward compatibility.

@yannham yannham force-pushed the task/label-interface branch 2 times, most recently from 9e8dea8 to 76b772c Compare March 1, 2023 18:20
@github-actions github-actions bot temporarily deployed to pull request March 1, 2023 18:24 Inactive
@github-actions github-actions bot temporarily deployed to pull request March 2, 2023 10:24 Inactive
@yannham yannham changed the title [WIP] Enrich label custom error reporting interface Enrich label custom reporting data Mar 2, 2023
@github-actions github-actions bot temporarily deployed to pull request March 2, 2023 18:50 Inactive
@yannham yannham marked this pull request as ready for review March 2, 2023 18:54
Add a `notes` field to the custom error reporting data carried by
contract labels. Move the tag (now renamed `message`) into a dedicated
data structure. A label now holds a stack of such custom contract
diagnostic, in order to avoid having subcontracts erase the previous
message and notes set by parent contracts.

This commits adapt error reporting to handle those new contract custom
diagnostics.

Note that this commit doesn't yet add user-code functions and primops to
access this new interface: it's mostly internal for now.
@github-actions github-actions bot temporarily deployed to pull request March 3, 2023 09:11 Inactive
src/error.rs Outdated Show resolved Hide resolved
src/error.rs Outdated Show resolved Hide resolved
src/error.rs Outdated Show resolved Hide resolved
src/eval/merge.rs Outdated Show resolved Hide resolved
src/label.rs Outdated Show resolved Hide resolved
@github-actions github-actions bot temporarily deployed to pull request March 3, 2023 10:23 Inactive
Copy link
Contributor

@ebresafegaga ebresafegaga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

lsp/nls/src/linearization/completed.rs Outdated Show resolved Hide resolved
@github-actions github-actions bot temporarily deployed to pull request March 3, 2023 15:26 Inactive
@yannham
Copy link
Member Author

yannham commented Mar 3, 2023

Oops, d77577b was pushed on the wrong branch. Will drop it and force push.

The contract diagnostics are set by usercode during evaluation. However,
the LSP was branching of the presence of such diagnostics to enrich its
error message. It doesn't make sense, as the LSP doesn't evaluate any
Nickel code, so contract diagnostics are always empty.

This commit remove the corresponding useless if.
@github-actions github-actions bot temporarily deployed to pull request March 3, 2023 16:40 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants