D Primary Type Syntax is Essentially Implemented!

Quirin Schroll qs.il.paperinik at gmail.com
Wed May 24 12:22:11 UTC 2023


On Wednesday, 24 May 2023 at 00:24:38 UTC, Basile B. wrote:
> On Tuesday, 23 May 2023 at 22:18:35 UTC, Quirin Schroll wrote:
>> [...]
>> I hope you like it.
>
> I like this solution more than the [alterantivey 
> proposed](https://github.com/dlang/dmd/pull/15245).

Did you link the right PR? It seems you linked my PR calling it 
the alternative to the post.

> Both work but yours try to be a bit more faithful to the 
> language. The alternative can look more seducing because it's 
> implemented by someone who knows his shits, so yeah it looks 
> nicer, the checks are greens but it is based on a special case.

This is why I took every minute of time I had to draft an 
implementation. This was stupidly hard! The compiler (parser at 
least) isn’t exactly well-documented. I did that because there’s 
a tendency of quick and dirty solutions to stick. *Nichts ist 
zählebiger als ein Provisorium.* (German proverb; “Nothing’s more 
tenacious than a makeshift.”)

> I'm very "pro" your way, problem is that currently the 
> implementation is not perfect
> (red checks).

This was my first DMD PR that could be called a meaningful 
attempt. I definitely need help by “someone who knows his shits.” 
I tried to fix things so that the problems would be solved.

---

If you (Basile B. or anyone reading this) would like to help, 
here’s a summary of the failed tests:
1. *CyberShadow/DAutoTest* checks that all the examples on the 
dlang.org website work. The one that fails is an intended 
breaking: `static assert(__traits(isSame, (e), 3))` (where `e` is 
an `enum` with value `3`) used to work but now fails.
2. *ci/circleci: build* has errors because “template instance 
`core.stdc.config._Complex!float` cannot resolve forward 
reference”.
3. I worked on the `fail_compilation`, but they still fail. (This 
accounts for a lot of failed tests, maybe even all except 1. and 
2.)

Comments:
1. This due to how `isSame` works: In essence, the reason is 
that, with the new grammar, `(e)` is not (necessarily) a primary 
expression anymore, therefore just putting parentheses around it 
is unsuited to force the evaluation as an expression; `(e)` 
becomes exactly equivalent to `e`, and `e` is a symbol, and 
`isSame` is always false if you compare a symbol with a literal. 
There’s two ways to tackle this: Change the example (e.g. use a 
cast) or change `isSame`. I’d prefer the former, but I don’t care 
much.
2. I don’t know what this means and I cannot reproduce this on my 
machine. The DMD files I changed I only touch the parser, but for 
all that I can tell this is a semantic problem. It even says that 
happened when instantiating the template, which has nothing to do 
with parsing.
3. The logs do not show the discrepancies of the expected and 
actual error messages, so it’s hard to know what is wrong. Maybe 
someone here knows how to get them.


More information about the Digitalmars-d mailing list