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

Fundamental type with suffix not allowed in expression grammar #4155

Open
tim-dlang opened this issue Dec 29, 2024 · 0 comments
Open

Fundamental type with suffix not allowed in expression grammar #4155

tim-dlang opened this issue Dec 29, 2024 · 0 comments

Comments

@tim-dlang
Copy link
Contributor

The following expressions are accepted by DMD, but not allowed by the grammar:

const e1 = int*.init;
const e2 = int[1].init;
const e3 = int*[0].init;

The grammar for PrimaryExpression only allows '(' or '.' after FundamentalType:

PrimaryExpression:
    ...
    FundamentalType . Identifier
    ...
    FundamentalType ( NamedArgumentListopt )
    ...

I assume DMD allows these expressions since this PR: dlang/dmd#14672
The parser contains the comment "defer error for better diagnostics", so maybe the new syntax is not allowed intentionally.

The new syntax is used by a test in druntime: https://github.com/dlang/dmd/blob/fb07d990466f185c2adb19d320627c2723d3978a/druntime/src/core/internal/traits.d#L625

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

No branches or pull requests

1 participant