"foo.bar !in baz" not allowed?

spir denis.spir at gmail.com
Sun Mar 13 13:27:27 PDT 2011


On 03/13/2011 07:58 PM, Magnus Lie Hetland wrote:
> For some reason, it seems like expressions of the form "foo.bar !in baz" aren't
> allowed. I suspect this is a grammar/parser problem -- the bang is interpreted
> as a template argument operator, rather than a negation operator, and there's
> really no need to make that interpretation when it is immediately followed by
> "in". This suspicion is strengthened by the fact that "bar !in baz" is fine, as
> is "(foo.bar) !in baz".
>
> Should I file this as a bug?
>
> Small sample program:
>
> struct Foo {
> uint bar;
> }
>
> struct Baz {
> bool opIn_r(uint e) {
> return false;
> }
> }
>
> void main() {
> Baz baz;
> Foo foo;
> auto res = (foo.bar) !in baz;
> res = !(foo.bar in baz);
> // res = foo.bar !in baz; // Not OK...
> uint frozz;
> res = frozz !in baz;
> }

Would be nice to copy the error, wouldn't it?
	template argument expected following !

Anyway, this is definitely a bug in my opinion.

Denis
-- 
_________________
vita es estrany
spir.wikidot.com



More information about the Digitalmars-d-learn mailing list