-
Notifications
You must be signed in to change notification settings - Fork 88
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9e8dea8
to
76b772c
Compare
cb67807
to
85cbe73
Compare
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.
85cbe73
to
1621d50
Compare
vkleen
reviewed
Mar 3, 2023
vkleen
reviewed
Mar 3, 2023
vkleen
reviewed
Mar 3, 2023
vkleen
reviewed
Mar 3, 2023
vkleen
reviewed
Mar 3, 2023
vkleen
approved these changes
Mar 3, 2023
ebresafegaga
approved these changes
Mar 3, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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.
d77577b
to
43c4a70
Compare
This was referenced Mar 3, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First step of #1052. Enrich the label interface for custom error reporting, with the additional
notes
field. Put this field, together with the previoustag
(nowmessage
) 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
ContractDiagnostic
s (should we also includetype_path
andarg_idx
, to store the type path and argument to parent contracts as well, and enrich the corresponding "parent" diagnostics) ?. Should we add more fields thannotes
to thelabel
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:Label
toContractDiagnostic
, 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.