I think this should compile: --- struct Foo { void bar(T)() {} void baz() {} } void main() { Foo foo; (foo).bar!int(); // Error: found '!' when expecting ';' following statement ((foo)).bar!int(); // OK foo.bar!int(); // OK (foo).baz(); // OK } --- (DMD 2.060 MacOSX)
This is an enhancement request against language syntax. --- > (foo).bar!int(); // Error: found '!' when expecting ';' following In current, "(foo).bar" matches UnaryExpression "(Type) . identifier". http://dlang.org/expression#UnaryExpression ("foo" is parsed as TypeIdentifier, and in semantic analysis phase, it will be finally analyzed as an expression.) Then, the remaining portions "!int();" don't match anything in the grammar. --- To allow it, we should add a case to UnaryExpression like follows: UnaryExpression: & UnaryExpression ++ UnaryExpression -- UnaryExpression * UnaryExpression - UnaryExpression + UnaryExpression ! UnaryExpression ComplementExpression ( Type ) . Identifier ( Type ) . TemplateInstance // new! NewExpression DeleteExpression CastExpression PowExpression
> In current, "(foo).bar" matches UnaryExpression "(Type) . identifier". > http://dlang.org/expression#UnaryExpression It should not since foo is not a type but an identifier. (foo).bar!int should match "PrimaryExpression . TemplateInstance", where PrimaryExpression matches "( Identifier )". So this is a compiler bug IMO, and should not be classified as an enhancement request.
(In reply to comment #2) > > In current, "(foo).bar" matches UnaryExpression "(Type) . identifier". > > http://dlang.org/expression#UnaryExpression > > It should not since foo is not a type but an identifier. > > (foo).bar!int should match "PrimaryExpression . TemplateInstance", where > PrimaryExpression matches "( Identifier )". > > So this is a compiler bug IMO, and should not be classified as an enhancement > request. OK. I was convinced that it is a grammar bug, rather than an enhancement. https://github.com/D-Programming-Language/dmd/pull/1422 https://github.com/D-Programming-Language/d-programming-language.org/pull/223
(In reply to comment #3) > (In reply to comment #2) > > > In current, "(foo).bar" matches UnaryExpression "(Type) . identifier". > > > http://dlang.org/expression#UnaryExpression > > > > It should not since foo is not a type but an identifier. > > > > (foo).bar!int should match "PrimaryExpression . TemplateInstance", where > > PrimaryExpression matches "( Identifier )". > > > > So this is a compiler bug IMO, and should not be classified as an enhancement > > request. > > OK. I was convinced that it is a grammar bug, rather than an enhancement. > > https://github.com/D-Programming-Language/dmd/pull/1422 > https://github.com/D-Programming-Language/d-programming-language.org/pull/223 It works fine with this pull request. And by studying it, I now understand how it works. Thanks.
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/d9a04e70c65fbdc29e1b157381c86e28d39ba739 fix Issue 9232 - Parsing error on some templated methods calls https://github.com/D-Programming-Language/dmd/commit/2d452f170a8f538ac4203195c2cd0e64a017691b Merge pull request #1422 from 9rnsr/fix9232 Issue 9232 - Parsing error on some templated methods calls
Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/3fa9b9a7a15e24dab28aeff0f5bf0f4e9f18ce06 Merge pull request #1422 from 9rnsr/fix9232 Issue 9232 - Parsing error on some templated methods calls
Commits pushed to master at https://github.com/D-Programming-Language/d-programming-language.org https://github.com/D-Programming-Language/d-programming-language.org/commit/92a1b3a127ab9ecf32b0aebbd82f7e81965bb1ca fix Issue 9232 - Parsing error on some templated methods calls https://github.com/D-Programming-Language/d-programming-language.org/commit/2596485da033b347f63606761d3fca296af93e9c Merge pull request #223 from 9rnsr/fix9232 Issue 9232 - Parsing error on some templated methods calls
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/bd0385c5410eec129f40b16d109f4719f97c4b21 Move issue 9232 test case to compilable/testparse.d
Commit pushed to stable at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/bd0385c5410eec129f40b16d109f4719f97c4b21 Move issue 9232 test case to compilable/testparse.d