Bug 24229 – Parser accepts fundamental types as primary expressions without dot identifier

Status
NEW
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-11-05T19:46:02Z
Last change time
2024-12-13T19:31:36Z
Keywords
accepts-invalid
Assigned to
No Owner
Creator
basile-z
Moved to GitHub: dmd#20352 →

Comments

Comment #0 by b2.temp — 2023-11-05T19:46:02Z
The rule for having a type like int, char, etc. as expression is, according to https://dlang.org/spec/expression.html#primary_expressions ```ebnf FundamentalType "." Identifier ``` so the following code should not parse ```d ubyte[] v() { ubyte[] buffer; buffer ~= char; // here the rhs return buffer; } enum ubyte a = v()[0]; ``` but instead it does and ends up with a semantic-time error.
Comment #1 by nick — 2024-11-08T15:41:57Z
> instead it does and ends up with a semantic-time error Is that a problem? That was intentional to fix issue 9848. Though that also meant things like this work: alias T = int; pragma(msg, int[T]); Before dmd 2.102 that was a parse error.
Comment #2 by b2.temp — 2024-11-09T10:24:32Z
It's not a problem but the specs need to be updated.
Comment #3 by robert.schadek — 2024-12-13T19:31:36Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20352 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB