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

feat(errors): make verrors=context global and update test outputs #17085

Closed

Conversation

royalpinto007
Copy link
Contributor

@royalpinto007 royalpinto007 commented Nov 23, 2024

Make verror=context usage global and update related test files accordingly.

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @royalpinto007! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#17085"

@royalpinto007 royalpinto007 marked this pull request as draft November 23, 2024 10:43
@royalpinto007 royalpinto007 force-pushed the verrors-context-global branch 3 times, most recently from 0081e4e to e3d8e37 Compare November 23, 2024 15:24
@dkorpel
Copy link
Contributor

dkorpel commented Nov 23, 2024

Was it decided somewhere that this should become the default? I prefer the current default, and don't like how this makes the test suite harder to maintain.

@royalpinto007 royalpinto007 force-pushed the verrors-context-global branch 2 times, most recently from 61d3006 to 18a28ac Compare November 23, 2024 17:07
@maxhaton
Copy link
Member

maxhaton commented Nov 23, 2024

Was it decided somewhere that this should become the default? I prefer the current default, and don't like how this makes the test suite harder to maintain.

Don't think so, but we are one of not many languages still not doing the squiggle by default. That debate aside, the last time I think someone (hatf0 I think) tried to turn it a bunch of things blew up so I asked @royalpinto007 to look into just to see how things were going on that front.

@thewilsonator thewilsonator added Merge:Blocked Review:Needs Changelog A changelog entry needs to be added to /changelog labels Nov 23, 2024
@bangbangsheshotmedown
Copy link
Contributor

Was it decided somewhere that this should become the default? I prefer the current default, and don't like how this makes the test suite harder to maintain.

I like this PR

With the code example, i know exactly what's wrong without having to decipher a lengthily message

I use Zig a lot and this is so much better

@royalpinto007 royalpinto007 force-pushed the verrors-context-global branch 13 times, most recently from 8df6f29 to ffd4b87 Compare November 29, 2024 14:10
@royalpinto007 royalpinto007 force-pushed the verrors-context-global branch 2 times, most recently from a3b801e to bc982a6 Compare December 1, 2024 10:04
@royalpinto007
Copy link
Contributor Author

royalpinto007 commented Dec 3, 2024

I need some help with the compilable/testcolor.sh file. I tried resolving it, but unfortunately, I wasn't able to.

@royalpinto007 royalpinto007 force-pushed the verrors-context-global branch 15 times, most recently from 5808d4e to 222a468 Compare December 4, 2024 20:04
@royalpinto007 royalpinto007 force-pushed the verrors-context-global branch from 222a468 to 3fa3274 Compare December 7, 2024 06:35
@royalpinto007 royalpinto007 marked this pull request as ready for review December 7, 2024 07:38
@thewilsonator thewilsonator removed Merge:Blocked Review:Needs Changelog A changelog entry needs to be added to /changelog labels Dec 8, 2024
@thewilsonator
Copy link
Contributor

ping @maxhaton please review

Copy link
Contributor

@RazvanN7 RazvanN7 left a comment

Choose a reason for hiding this comment

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

I like it.

Copy link
Contributor

@dkorpel dkorpel left a comment

Choose a reason for hiding this comment

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

I don't know if it's a good idea to switch the default, I'll bring that up tomorrow in the DLF monthly meeting.

However, the test suite doesn't have to use the default. It's interesting to see what all these errors now look like with -verrors=context, but it also makes me notice that often, the column location is wrong. So this is very useful to spot all the places where error locations can be improved, but perhaps we shouldn't promote -verrors=context yet while it's inaccurate so many times.

I also notice the way the tests are updated is that #line markers are removed and all test output blocks are merged and put at the beginning. This means that now, a small change in the test will cause a large diff in a big output block. The original structure was supposed to prevent that. I have been working on a special test runner directive that allows local, line number-independent error messages: #14515

In any case, I don't think the 5000 new copied lines of code with an error are worth adding to the test suite.

Comment on lines +368 to +384
this.index = 0;
this.eolIndex = 0;
this.nextIndex = 0;
}

public bool empty() { return index == text.length; }
public bool empty() { advance(); return index >= text.length; }

public void popFront() { advance(); index = nextIndex; }

public const(char)[] front() { advance(); return text[index .. eolIndex]; }
public const(char)[] front()
{
advance();
if (index > eolIndex || index >= text.length) {
return "";
}
return text[index .. eolIndex];
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What's this change for, does this PR uncover a bug in splitLines?

---
*/

#line 1
// Line 1 starts here
Copy link
Contributor

Choose a reason for hiding this comment

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

But it doesn't, this comment makes no sense when there's no #line 1 directive anymore

Comment on lines +4 to +6
compilable/b16976.d(73): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`
foreach(int i, v; dyn) { }
^
Copy link
Contributor

Choose a reason for hiding this comment

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

Caret is in the wrong position

Comment on lines +6 to +8
compilable/compile1.d(232): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead
cdouble c6096;
^
Copy link
Contributor

Choose a reason for hiding this comment

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

Caret is in the wrong position

compilable/sw_transition_complex.d(39): Deprecation: use of imaginary type `idouble*` is deprecated, use `double` instead
compilable/sw_transition_complex.d(40): Deprecation: use of imaginary type `ifloat*` is deprecated, use `float` instead
---
*/
creal* c80pointer;
cdouble* c64pointer;
cfloat* c32pointer;
Copy link
Contributor

Choose a reason for hiding this comment

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

The messages are no longer local to the relevant code.

@@ -0,0 +1,33 @@
Make `verror=context` Usage Global and Update Related Test Files
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Make `verror=context` Usage Global and Update Related Test Files
Enable `-verrors=context` by default

Test suite changes are irrelevant to users.

@@ -0,0 +1,33 @@
Make `verror=context` Usage Global and Update Related Test Files

The `verror=context` error handling mechanism has been made global, ensuring that error messages now consistently include context information across the entire codebase. Previously, error handling was localized, leading to some errors lacking context in the output.
Copy link
Contributor

@dkorpel dkorpel Dec 12, 2024

Choose a reason for hiding this comment

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

This is a weird description: all -verrors=context does is print the line of code the error applies to under the message. It has nothing to do with 'across the entire codebase' vs 'localized'.

@maxhaton
Copy link
Member

Consensus: enable this for users, disable it in almost all of the test suite for visual noise.

@royalpinto007 thank you very much for updating the tests though. We can't enable it without making sure it works acorss the whole test suite without blowing up! Now we can.

Can we name the option to turn it off -verrors=simple?

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.

7 participants