January 18, 2022
On Mon, Jan 17, 2022 at 05:23:26PM -0800, H. S. Teoh via Digitalmars-d wrote: [...]
> I'll take a look at the code now to see if there's anything easily salvageable...  but at this point I'm ready to propose pulling the trigger on -profile=gc completely.  (Based on how I suspect it works, I'm expecting that it would not be easy to implement any useful output for allocations via druntime functions -- at best you'd just get some obscure file/line number inside druntime code which would be of no help locating where in *your* code the allocation happened.)
[...]

Outlined a few possible approaches to fix this here:

	https://issues.dlang.org/show_bug.cgi?id=14892#c1

I'm not sure I have the compiler chops to actually fix this myself, though.  This is a little beyond my level of familiarity with dmd code. Would be nice if somebody picked this up.

Also, druntime/src/rt/profilegc.d seriously needs to be fixed to *always* write to the file profilegc.txt when compiled with -profile=gc (https://issues.dlang.org/show_bug.cgi?id=19601). Added a note there also re: possible fixes.


T

-- 
It is impossible to make anything foolproof because fools are so ingenious. -- Sammy
January 18, 2022
On Tue, Jan 18, 2022 at 03:32:14PM +0000, bachmeier via Digitalmars-d wrote:
> On Tuesday, 18 January 2022 at 12:58:17 UTC, Adam D Ruppe wrote:
> > On Tuesday, 18 January 2022 at 09:21:11 UTC, Walter Bright wrote:
> > > For example, not too long ago, there were some major frustrations posted about the compiler's bad error messages. No examples were given, and no bugzilla entries had been posted. There's nothing anyone who wants to help can do about that.
> > 
> > If you actually used D for any real work, you wouldn't need a bugzilla issue to know the error messages are really bad.
> 
> I'm inclined to say there's a lower standard for error messages if you're the one that wrote the compiler.

It's the familiarity syndrome.  If you're the one who wrote the compiler, you already have a deep understanding of how it works internally, and that understanding colors your perception of the error mesage.  However, someone who *didn't* write the compiler has no idea where the compiler is coming from, so to speak, and so what's obvious to you may be completely opaque to him.

Familiarity also biases you, so that you fail to see flaws that are obvious to everyone else, because you have been acclimatized to expect certain things and unconsciously assume they are there even when they're actually missing.  Just like how spectators to a chess game often notice things that the heavily-invested players may miss, because they're too focused on seeing the game from one particular viewpoint and thus may neglect some other aspect.


T

-- 
Never trust an operating system you don't have source for! -- Martin Schulze
January 18, 2022
On Tuesday, 18 January 2022 at 14:18:15 UTC, jmh530 wrote:
> Walter: Please file bug reports about bad error messages so that they can get improved
> Forum: But error messages are so bad.
> Repeat

Open issues reported by me (39) ranging from 2014-02-25 through 2021-09-13

Specifically about error messages:

[diagnostic] Name suggest for override should only list virtual functions 	2019-08-23
Improve inferred attribute error message 	2021-08-16
[regression] opDispatch error disappears! 	2020-08-05
deprecation warning on reflection should be suppressed or at least suppressable 	2021-05-04


Fewer than half my reported bugs have ever been fixed. Of the old error message ones, two have been fixed: one from 2013 and one from 2021.... only because I did it myself.

Bugzilla has plenty of issues in it.
January 18, 2022
On Tuesday, 18 January 2022 at 09:21:11 UTC, Walter Bright wrote:
> ...

For what it's worth I did try to help out with getting better error messages, but the PR seems to have stalled for reasons beyond me: https://github.com/dlang/dmd/pull/12526
January 18, 2022
On Tue, Jan 18, 2022 at 04:40:11PM +0000, SealabJaster via Digitalmars-d wrote:
> On Tuesday, 18 January 2022 at 09:21:11 UTC, Walter Bright wrote:
> > ...
> 
> For what it's worth I did try to help out with getting better error messages, but the PR seems to have stalled for reasons beyond me: https://github.com/dlang/dmd/pull/12526

Took a quick look, apparently there's one pending change requested by Iain?  Maybe ping him to review this to see if it's resolved?

Also, autotester is failing. Should probably look into that, or explain why it's not relevant.


T

-- 
My father told me I wasn't at all afraid of hard work. I could lie down right next to it and go to sleep. -- Walter Bright
January 18, 2022
On Tuesday, 18 January 2022 at 12:51:33 UTC, deadalnix wrote:
> On Tuesday, 18 January 2022 at 08:36:18 UTC, user1234 wrote:
>> On Tuesday, 18 January 2022 at 03:30:53 UTC, Walter Bright wrote:
>>> On 1/17/2022 6:06 PM, deadalnix wrote:
>>>> Modern formatter, such as clang-format, use a parser, but the parser generates an IR that as nothing to do with the traditional AST you'd get out of a regular parser.
>>>
>>> What comes to mind is what to do with the comments.
>>
>> They must be kept, which is what dfmt does as it follows the token stream and *not* the AST.
>
> See https://forum.dlang.org/post/givmbzmvnjnweozrexgm@forum.dlang.org

yeah dfmt does works like I say https://github.com/dlang-community/dfmt/blob/master/src/dfmt/formatter.d.
January 18, 2022
On Tuesday, 18 January 2022 at 17:09:46 UTC, user1234 wrote:
> On Tuesday, 18 January 2022 at 12:51:33 UTC, deadalnix wrote:
>> On Tuesday, 18 January 2022 at 08:36:18 UTC, user1234 wrote:
>>> On Tuesday, 18 January 2022 at 03:30:53 UTC, Walter Bright wrote:
>>>> On 1/17/2022 6:06 PM, deadalnix wrote:
>>>>> Modern formatter, such as clang-format, use a parser, but the parser generates an IR that as nothing to do with the traditional AST you'd get out of a regular parser.
>>>>
>>>> What comes to mind is what to do with the comments.
>>>
>>> They must be kept, which is what dfmt does as it follows the token stream and *not* the AST.
>>
>> See https://forum.dlang.org/post/givmbzmvnjnweozrexgm@forum.dlang.org
>
> yeah dfmt does works like I say https://github.com/dlang-community/dfmt/blob/master/src/dfmt/formatter.d.

It's certainly not an AST walker ;)
January 18, 2022
On Tue, Jan 18, 2022 at 07:37:42AM -0800, H. S. Teoh via Digitalmars-d wrote: [...]
> Outlined a few possible approaches to fix this here:
> 
> 	https://issues.dlang.org/show_bug.cgi?id=14892#c1
> 
> I'm not sure I have the compiler chops to actually fix this myself, though.  This is a little beyond my level of familiarity with dmd code.  Would be nice if somebody picked this up.
[...]

OK, so to *completely* fix this may be a little beyond me, but a partial fix that at least covers std.array.array was within reach.  So I changed dmd to set a new predefined version D_ProfileGC, extended rt/tracegc.d to wrap the specific druntime call std.array.array uses, and modified Phobos to call the wrapped function instead when version=D_ProfileGC.

With these changes, I successfully got -profile=gc to detect allocations from std.array.array!

However, this fix is not complete yet, because currently profilegc.txt shows the allocation coming from some obscure line deep inside Phobos internals, which is very user-unfriendly. It will take a bit more work to properly propagate file/line/function information from user code down to the point of allocation.


T

-- 
English is useful because it is a mess. Since English is a mess, it maps well onto the problem space, which is also a mess, which we call reality. Similarly, Perl was designed to be a mess, though in the nicest of all possible ways. -- Larry Wall
January 18, 2022
On 1/18/2022 4:58 AM, Adam D Ruppe wrote:
> If you actually used D for any real work, you wouldn't need a bugzilla issue to know the error messages are really bad.

"Everybody knows" is not a substitute for putting issues on bugzilla. Besides, dmd has what, 500 error messages? Guessing which one is somebody else's issue is not a productive use of time. Guessing what code they had that triggered the message is also a complete waste of time. I can't read anybody's mind.

P.S. I use D for real work, every day.
January 18, 2022
On 1/18/2022 7:47 AM, Adam D Ruppe wrote:
> Fewer than half my reported bugs have ever been fixed. Of the old error message ones, two have been fixed: one from 2013 and one from 2021.... only because I did it myself.

I fix plenty of bugs that I filed myself :-)


> Bugzilla has plenty of issues in it.

Bugzilla has lots of issues. Please don't make us guess what you're referring to. If you want to bring up a specific issue here, please provide a link.