need examples to understand postfix expression grammar
FabArd
hoarau.fabrice at free.fr
Wed Apr 19 15:40:32 UTC 2023
Thank you for your examples.
I did some tests based on your examples and I found that you can
also assign a type to an auto variable:
```d
void main(){
auto x = double();
x = 2;
static assert(is(typeof(x) == double));
assert(x == 2);
}
```
Another example with a qualified identifier:
```d
class Test {
enum nb : int {
one = 1
}
}
void main(){
auto d = Test.nb();
static assert(is(typeof(d) == Test.nb));
}
```
It seems that the grammar rule could be written more precisely:
PostfixExpression:
- PostfixExpression ( ArgumentListopt )
- TypeCtors<opt> BasicType ( AssignExpressionopt )
Indeed the type conversion takes only one or no argument but
never a list.
More information about the Digitalmars-d
mailing list